.htaccess stop a php redirect?

2019-08-28 09:04发布

I currently have WordPress installed for our site - I'm trying to do a simple php redirect for our site for incoming mobile browsers to be redirected to our mobile site... However, when I put the script in, nothing happens, no redirect, the site just acts normal.

Now we have 3 other WordPress installs (as vhosts on the same server) and I can get the redirect working on all the other installs, just not the one we want it to work on (of course), the only glaring differences are the htaccess files. I'm no htaccess master, so my only thought is that something in the htaccess file is preventing my PHP redirect, is this possible?

Or are there any other possibilities that I'm missing?

RewriteEngine On


# BEGIN W3 Total Cache
<IfModule mod_setenvif.c>
SetEnvIfNoCase Accept-Encoding (gzip|deflate) APPEND_EXT=.$1
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} \/$
RewriteCond %{REQUEST_URI} !(\/wp-admin\/|\/xmlrpc.php|\/wp-  (app|cron|login|register).php|wp-.*\.php|index\.php) [OR]
RewriteCond %{REQUEST_URI} (wp-comments-popup\.php|wp-links-opml\.php|wp-locations\.php) [NC]
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} =""
RewriteCond %{HTTP_COOKIE} !(comment_author|wp-postpass|wordpress_\[a-f0-9\]\+|wordpress_logged_in) [NC]
RewriteCond %{HTTP_USER_AGENT} !(bot|ia_archive|slurp|crawl|spider) [NC]
RewriteCond /var/www/wordpress/wp-content/w3tc/pgcache/$1/_default_.html%{ENV:APPEND_EXT} -f
RewriteRule (.*) wp-content/w3tc/pgcache/$1/_default_.html%{ENV:APPEND_EXT} [L]
</IfModule>
# END W3 Total Cache

# Performance Options
Header unset Pragma
FileETag None
Header unset ETag

# 1 YEAR
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4)$">
Header set Cache-Control "public"
Header set Expires "Thu, 18 Apr 2011 20:00:00 GMT"
Header unset Last-Modified
</FilesMatch>

# 2 HOURS
<FilesMatch "\.(html|htm|xml|txt|xsl)$">
Header set Cache-Control "max-age=7200, must-revalidate"
</FilesMatch>

# CACHED FOREVER
# MOD_REWRITE TO RENAME EVERY CHANGE
<FilesMatch "\.(js|css)$">
Header set Cache-Control "public"
Header set Expires "Thu, 15 Apr 2019 20:00:00 GMT"
Header unset Last-Modified
</FilesMatch>


AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-    javascript

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !.*.(?:gif|jpg|png|pdf|mp3|avi|mpeg|bmp|mov|ico)

RewriteRule . /index.php [L]
</IfModule>

# END WordPress

# protect the htaccess file
<files .htaccess>
order allow,deny
deny from all
</files>

# protect wpconfig.php
<files wp-config.php>
order allow,deny
deny from all
</files>

# Error Document
ErrorDocument 403 /error/403/index.html

# deny directory listings
Options -Indexes

1条回答
相关推荐>>
2楼-- · 2019-08-28 09:31

I actually solved this on my own and I was far to over thinking the issue and forgot to check the more obvious things first. Seems that the cache plugin I was using was stopping the redirect and it took me three days before it finally dawned on me that caching would prevent a redirect.

查看更多
登录 后发表回答