.htaccess停止PHP重定向? [英] .htaccess stop a php redirect?

查看:83
本文介绍了.htaccess停止PHP重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前为我们的网站安装了WordPress-我正在尝试为我们的网站执行简单的php重定向,以将传入的移动浏览器重定向到我们的移动网站...但是,当我将脚本放入时,什么也没有发生,没有重定向,该站点只能正常运行。

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.

现在我们有3个其他WordPress安装(作为同一服务器上的虚拟主机),我可以将重定向用于所有其他安装,而不仅仅是我们想要的安装要工作(当然),唯一明显的区别是htaccess文件。我不是htaccess管理员,所以我唯一想到的是htaccess文件中的某些内容阻止了我的PHP重定向,这可能吗?

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


推荐答案

我实际上是自己解决了这个问题,我还远远没有考虑这个问题,忘了先检查更明显的事情。似乎我使用的缓存插件正在停止重定向,并且花了我三天时间才终于意识到缓存可以阻止重定向。

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.

这篇关于.htaccess停止PHP重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆