.htaccess - Redirect not working for Wordpress Site
I have this RewriteRule Here:
RewriteRule ^TWI$ https://www.paypal.com
But its not working, basically what I am trying to do is have a page like so https://example.com/TWI redirect to paypal's website. What am I doing wrong? Here are are rest of my rules:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^TWI$ https://www.paypal.com
</IfModule>
1 answer
-
answered 2019-08-13 07:03
JarekBaran
I have changed the order of the rules, please check:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^TWI$ https://www.paypal.com [R=301,L] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>
See also questions close to this topic
-
How to hide specific urls from adsense?
I am a new here so pardon me, if I am wrong. I am using WordPress as CMS on my site right now. I want to hide a few of my AdSense approved site URLs, though I want to show the ads on those pages. I just don't want AdSense to see those pages. What I have seen a few of my other competitors do is they are generating PHP URLs, such as (example.com/folder/filename.php?file=k1GFLvHzp131fQvuw3v) I want to know what is this PHP file doing, and is it helping to hide page from Adsense. This URL is basically for live streaming. So, In this URL "filename.php" changes for different servers and "file=k1GFLvHzp131fQvuw3v" changes for a specific server on different iframes... So, please can anyone help me understand this.
-
BuddyPress returning incorrect xprofile date
It was all working fine but all of sudden BuddyPress xprofile
date
field giving one date before. However, I have checked in the database and the entry is correct. It is just returning the wrong date.This means, If I set the date to 1920-12-12 it is storing the correct (the same) but returning 1920-12-11.
I am getting the date using the following BuddyPress function.
// tried by field id bp_get_profile_field_data([ 'field' => 5, 'user_id' => 14 ]); // tried by field name bp_get_profile_field_data([ 'field' => 'Date Of Birth', 'user_id' => 14 ]);
-
Best way to show webp images in both AMP and non-amp page
I am using AMP Plugin in transitional mode in my wordpress blog. I use following code to show webp images in both amp and non amp page.
<picture> <source srcset="https://allfullform.com/wp-content/uploads/2019/12/bae.webp" type="image/webp"> <img src="https://allfullform.com/wp-content/uploads/2019/12/bae.jpg" alt="BAE full form" class="wp-block-image"> </picture> <amp-img alt="BAE Full Form" class="wp-block-image" width="799" height="687" layout="responsive" src="https://allfullform.com/wp-content/uploads/2019/12/bae.webp"> <amp-img alt="BAE Full Form" class="wp-block-image" fallback="" width="1000" height="859" layout="responsive" src="https://allfullform.com/wp-content/uploads/2019/12/bae.jpg"></amp-img> </amp-img>
I am using above code in this blog. For AMP version add "/amp" at the end of url.
In AMP pages code inside picture tag will not loads so I think no problem in AMP pages.
Is there any negative impact in my non amp page's seo? Whether it is best practice to show webp images in both AMP and non amp version?
-
AuthUserFile/.htpasswd if URL matches regex
I'm using a software on a subdomain a.example.com
The access to this URL should be secured by an additional .htpasswd, except for those URLs, which have to be publicly accessible:
- a.example.com/foo.js
- a.example.com/foo.php
- a.example.com/index.php?module=Foo&action=Bar
I achieved to handle 1 and 2, but cannot handle 3, due to the fact, that a request to a.example.com/index.php or a.example.com/index.php?module=Secret should be restricted.
<Files "*"> Require valid-user </Files> <Files ~ "^foo\.(js|php)$"> Allow from all Satisfy any </Files> AuthUserFile /foo/bar/.htpasswd AuthGroupFile /dev/null AuthName 'Restricted' AuthType Basic require valid-user
How can I handle 3.? Is there a way to read the GET-Parameters?
-
Domain Redirects - Not all working - HTTPS time out / not redirecting
Ok the following are the urls for my site, ones marked with a tick work fine but the ones marked with an x either time out, or give an error like "This site can’t be reached domain.tld’s server IP address could not be found." in chrome.
I want all to redirect to https://taibhsedesigns.ie
(✓) https://www.taibhsedesigns.ie (✓) http://www.taibhsedesigns.ie (✓) https://taibhsedesigns.ie (x) http://taibhsedesigns.ie (✓) www.taibhsedesigns.ie (x) taibhsedesigns.ie (x) https://www.taibhsedesigns.com (✓) http://www.taibhsedesigns.com (x) https://taibhsedesigns.com (✓) http://taibhsedesigns.com (✓) www.taibhsedesigns.com (✓) taibhsedesigns.com
So for details, my site is setup with blacknight Ireland, there is an ssl cert for the .ie domain, I don't have one for the .com domain so how can I fix timeouts for the https attempts at the .com domains or make them go to the http version and have it then redirect to the .ie?
Site is hosted on the .ie url with the .com setup to forward using standard forwarding in the control panel with black night.
My htaccess file for the .ie domain is as follows and the site is built using codeigniter,
RewriteEngine on #remove index.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php/$0 [PT,L] #force https RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} #all below is custom and not orig to codeigniter #redirects for broken links from old website Redirect /index.html https://taibhsedesigns.ie/ Redirect /faq.html https://taibhsedesigns.ie/faq Redirect /privacy.html https://taibhsedesigns.ie/privacy Redirect /portfolio.php https://taibhsedesigns.ie/portfolio <IfModule mod_deflate.c> # Insert filters / compress text, html, javascript, css, xml: AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/javascript AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE text/vtt AddOutputFilterByType DEFLATE text/x-component AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/js AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/x-httpd-php AddOutputFilterByType DEFLATE application/x-httpd-fastphp AddOutputFilterByType DEFLATE application/atom+xml AddOutputFilterByType DEFLATE application/json AddOutputFilterByType DEFLATE application/ld+json AddOutputFilterByType DEFLATE application/vnd.ms-fontobject AddOutputFilterByType DEFLATE application/x-font-ttf AddOutputFilterByType DEFLATE application/x-web-app-manifest+json AddOutputFilterByType DEFLATE font/opentype AddOutputFilterByType DEFLATE image/svg+xml AddOutputFilterByType DEFLATE image/x-icon # Exception: Images SetEnvIfNoCase REQUEST_URI \.(?:gif|jpg|jpeg|png)$ no-gzip dont-vary # Drop problematic browsers BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html # Make sure proxies don't deliver the wrong content <IfModule mod_headers.c> Header append Vary User-Agent env=!dont-vary </IfModule> </IfModule> <IfModule mod_gzip.c> mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$ mod_gzip_item_include handler ^cgi-script$ mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item_exclude mime ^image/.* mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* </IfModule> # ---------------------------------------------------------------------- # Gzip compression # ---------------------------------------------------------------------- <IfModule mod_deflate.c> # Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/ <IfModule mod_setenvif.c> <IfModule mod_headers.c> SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding </IfModule> </IfModule> # HTML, TXT, CSS, JavaScript, JSON, XML, HTC: <IfModule filter_module> FilterDeclare COMPRESS FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css FilterProvider COMPRESS DEFLATE resp=Content-Type $text/plain FilterProvider COMPRESS DEFLATE resp=Content-Type $text/xml FilterProvider COMPRESS DEFLATE resp=Content-Type $text/x-component FilterProvider COMPRESS DEFLATE resp=Content-Type $application/javascript FilterProvider COMPRESS DEFLATE resp=Content-Type $application/json FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xhtml+xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/rss+xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/atom+xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/vnd.ms-fontobject FilterProvider COMPRESS DEFLATE resp=Content-Type $image/svg+xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/x-font-ttf FilterProvider COMPRESS DEFLATE resp=Content-Type $font/opentype FilterChain COMPRESS FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no </IfModule> <IfModule !mod_filter.c> # Legacy versions of Apache AddOutputFilterByType DEFLATE text/html text/plain text/css application/json AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE text/xml application/xml text/x-component AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml AddOutputFilterByType DEFLATE image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype </IfModule> </IfModule> #protection from mime sniffing and security exploit <IfModule mod_headers.c> Header always set X-Content-Type-Options "nosniff" </IfModule> #Block access to the entire page when an XSS attack is suspected <IfModule mod_headers.c> Header always set X-XSS-Protection "1; mode=block" </IfModule> #prevent click jacking and disallow pages being embedded in iframes on other sites <IfModule mod_headers.c> Header always set X-FRAME-OPTIONS "SAMEORIGIN" </IfModule> # Disable server signature for security ServerSignature Off
-
RewriteRule appends unwanted string
I don't want to blame RewriteRule, but so it looks to me.
Minimal example. In the real code, the first Rule does some prepending, so it has some meaning, as opposed to this.
RewriteRule ^(.*)$ $1 RewriteCond %{REQUEST_URI} ^/pre RewriteRule ^(.*)$ /post=$1 [R=301,L]
When submitted URL is
example.com/pre/sub
, I am getting 301 toexample.com/post=pre/sub/sub
. I have no idea where that second sub is coming from.The way I think this should work. First rule
$1
ispre/sub
and so it rewritespre/sub
topre/sub
. The cond checks whether REQUEST_URI starts with /pre and prevents looping and the last rule matches everything so$1
ispre/sub
and it appends it creating/post=pre/sub
, to which it is then redirected. But the browser gets/post=/pre/sub/sub
.Some testing I have done:
Submitting only
example.com/pre
results in expected/post=pre
;When I modify the example to
RewriteRule ^(.*)$ -$1- RewriteCond %{REQUEST_URI} ^/pre RewriteRule ^(.*)$ /post=&$1& [R=301,L]
The resulting redirect is to
/post=&-pre/sub-/sub&
meaning it is appended "after" the first rule, but "before" the second one. But where and how?