我想使用Apache RewriteRule将URL目标页面更改为abc.php。我已经设置了RewriteEngine,但是我发现了这个问题。无法使用Apache RewriteRule
正则表达式我用:
RewriteRule ^viewthread\.php.tid=12345$ abc.php
的URL字符串匹配:
viewthread.php?tid=12345
为什么它不匹配成功?
我想使用Apache RewriteRule将URL目标页面更改为abc.php。我已经设置了RewriteEngine,但是我发现了这个问题。无法使用Apache RewriteRule
正则表达式我用:
RewriteRule ^viewthread\.php.tid=12345$ abc.php
的URL字符串匹配:
viewthread.php?tid=12345
为什么它不匹配成功?
重写与查询字符串的URL略高于重写纯网址时更加复杂。你必须写这样的事:
RewriteCond %{REQUEST_URI} ^/viewthread\.php$
RewriteCond %{QUERY_STRING} ^tid=12345$
RewriteRule ^(.*)$ http://mydomain.site/abc.php [R=302,L]
看到那些文章以获得更多帮助:
我想因为你错过了?在规则...
RewriteRule ^viewthread.php?tid=12345$ abc.php
它不应该是:
RewriteRule ^/viewthread\.php\?tid=12345$ /abc.php
我有尝试之前,但失败 – user1155641 2012-01-19 01:18:45
打开日志记录并粘贴一个片段,以便我们可以确切地知道发生了什么 – 2012-01-19 04:42:22
我以前也试过,但失败了 – user1155641 2012-01-19 01:18:28