htaccess 重写规则不重定向?
htaccess Rewrite Rule Not Redirecting?
我有下面的重写规则,但我一直无法弄清楚为什么它不起作用,任何日志中都没有错误,屏幕上也没有显示任何内容,我很困惑。
它获取会话令牌并将其传递给 url。
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^/\?action=logout;(.*)$ /forum/index.php?action=logout; [NC,L]
我也试过这个,但没有运气,没有错误或任何提示问题的东西。
RewriteCond %{QUERY_STRING} ^action=logout
RewriteRule ^/\?action=logout;(.*)$ /forum/index.php?action=logout; [L,R=301]
使用 QUERY_STRING
是一个好的开始。
无论如何,您现在需要在规则中匹配 /
或 /index.php
。
此外,由于您传递的是相同的查询字符串,因此不需要捕获其中的一部分。您可以改用 QSA
标志。
RewriteCond %{QUERY_STRING} ^action=logout [NC]
RewriteRule ^/?(?:index\.php)?$ /forum/index.php [L,NC,R=301,QSA]
如果你想要静默重定向(内部重写),只需删除 R=301
标志
我有下面的重写规则,但我一直无法弄清楚为什么它不起作用,任何日志中都没有错误,屏幕上也没有显示任何内容,我很困惑。
它获取会话令牌并将其传递给 url。
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^/\?action=logout;(.*)$ /forum/index.php?action=logout; [NC,L]
我也试过这个,但没有运气,没有错误或任何提示问题的东西。
RewriteCond %{QUERY_STRING} ^action=logout
RewriteRule ^/\?action=logout;(.*)$ /forum/index.php?action=logout; [L,R=301]
使用 QUERY_STRING
是一个好的开始。
无论如何,您现在需要在规则中匹配 /
或 /index.php
。
此外,由于您传递的是相同的查询字符串,因此不需要捕获其中的一部分。您可以改用 QSA
标志。
RewriteCond %{QUERY_STRING} ^action=logout [NC]
RewriteRule ^/?(?:index\.php)?$ /forum/index.php [L,NC,R=301,QSA]
如果你想要静默重定向(内部重写),只需删除 R=301
标志