问题描述
我有这样的情况:
如 /sport.html
所有URL隐藏真实的URL /archive.php?action=search§ion=sport
#这个是规则:
重写规则^([A-ZA-Z _] +([A-ZA-Z0-9 _] +)?)( - ([0-9] +))\ HTML $ /archive.php?action=search&?。部分= $ 1 [L]
现在我想隐藏真实的URL和所有直接访问的页面 archive.php
,但我收到重定向循环错误此规则:
重写规则^档案\的.php。* $ /404.html [F,NC,L]
我想你实际上是在寻找的不是这样的:
重写规则^档案\的.php。* $ /404.html [F,NC,L]
由于很明显,这将导致一个循环,因为你的第一条规则被改写为 archive.php
,并且该规则将其重写为别的,等等等等。
尝试,而不是上面的规则这样的:
的RewriteCond%{THE_REQUEST} \ /archive\.php
重写规则^ /404.html [F,L]
或者,如果你想成为看中它:
的RewriteCond%{THE_REQUEST} \ /archive\.php\?action=search§ion =([^&放大器; \] +)
重写规则^ /%1.html [R,L]
I have this situation:
all urls like /sport.html
hide the real url /archive.php?action=search§ion=sport
#This is the RULE:
RewriteRule ^([a-zA-Z_]+([a-zA-Z0-9_]+)?)(-([0-9]+))?\.html$ /archive.php?action=search§ion=$1 [L]
Now I want to hide the real url and all direct access to the page archive.php
but I receive the redirect loop error with this rule:
RewriteRule ^archive\.php.*$ /404.html [F,NC,L]
I think what you're actually looking for isn't this:
RewriteRule ^archive\.php.*$ /404.html [F,NC,L]
As obviously, this causes a loop, since your first rule is rewriting to archive.php
, and this rule rewrites it to something else, etc. etc.
Try this instead of the above rule:
RewriteCond %{THE_REQUEST} \ /archive\.php
RewriteRule ^ /404.html [F,L]
Or, if you want to be fancy about it:
RewriteCond %{THE_REQUEST} \ /archive\.php\?action=search§ion=([^&\ ]+)
RewriteRule ^ /%1.html [R,L]
这篇关于如何在$ htaccess的p $ pvent无限重定向循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!