Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php HTACCESS如何与代码抗争以获得正确的重定向_Php_.htaccess_Url_Mod Rewrite - Fatal编程技术网

Php HTACCESS如何与代码抗争以获得正确的重定向

Php HTACCESS如何与代码抗争以获得正确的重定向,php,.htaccess,url,mod-rewrite,Php,.htaccess,Url,Mod Rewrite,我的HTACCESS文件当前看起来如下所示: RewriteEngine On RewriteBase / # stop directory listings #Options -Indexes #stops htaccess views #<Files .htaccess> #order allow,deny #deny from all #</Files> # redirect game folders Rewrite

我的HTACCESS文件当前看起来如下所示:

RewriteEngine On        
RewriteBase /

# stop directory listings
#Options -Indexes 

#stops htaccess views
#<Files .htaccess>
#order allow,deny
#deny from all
#</Files>        

# redirect game folders     
RewriteRule ^games/([^/]+)/([^/]+) games.php?author=$1&slug=$2 [L]   

# redirect edit     
RewriteRule ^protected/edit-game/([^/]+)/([^/]+) protected/edit-game.php?author=$1&slug=$2 [L] 
RewriteRule ^admin/edit-game/([^/]+)/([^/]+) admin/edit-game.php?author=$1&slug=$2 [L]

# redirect view     
RewriteRule ^protected/view-game/([^/]+)/([^/]+) protected/view-game.php?author=$1&slug=$2 [L]   

# redirect user
RewriteRule ^page/([^/]+) user.php?user=$1 [L]  

# remove .php; use THE_REQUEST to prevent infinite loops
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
RewriteRule (.*)\.php$ $1 [R=301]     

# remove index
RewriteRule (.*)/index$ $1/ [R=301]

# remove slash if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]

# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]   

ErrorDocument 404 /error-404.php
# redirect pages/posts 
RewriteRule ^([^/]+) page.php?slug=$1 [L]     
它只会覆盖以前可能成功的所有重写,并显示my page.php,而不管它放在htaccess文件中的什么位置??我想我的意思是如果规则被认可。。。它应该停止做任何事情。因此,如果我将新行放在所有重定向下,它应该最后进行页面检查。。但是没有:


有什么想法吗?

也许是因为你的301重定向?浏览器会缓存这些重定向,因此您必须尝试其他浏览器或清除缓存。

hm。。不,这似乎不仅仅是缓存问题。唉,很难100%说出来,因为我已经使用了我所有的浏览器。。但我在所有浏览器上都额外按下了ctrl+F5,关闭并重新打开了firefox和iegay。。我是说ie9*你的firefox在关闭时会自动清理缓存吗?否则你自己去清理它该死的,不。只是再试一次。我假设代码有问题,而不是希望它只是缓存问题。我刚刚清空了ie9和firefox的缓存,当然chrome也不能正常工作。为此干杯,我以前也遇到过缓存问题有没有更好的办法。好吧,我现在有一个巨大的应用程序,需要一些时间来重新编码,但如果有更好的方法来完成上述所有工作的话。请告诉我。我开始觉得我可能需要重新编写很多代码,而不是用大量的htaccess重写来重定向页面。如果我以静默方式将所有url重定向到一个页面,那么我可以根据url包含特定的文件,这可能更好…?有没有调试htaccess文件的方法?像是记录它做了什么?