我只需要重写一个特定的URL,就可以向访问者显示特定的内容:我尝试了这样的方法:
RewriteEngine on
RewriteCond %{REQUEST_URI} example.com/test/2_5/page.html
RewriteRule ^(.*)$ example.com/tt.html [R,L]
我需要将所有请求重写为:
http://example.com/test/2_5/page.html
至
http://example.com/tt.html
如何做到这一点?
谢谢,
Redirect /test/2_5/page.html /tt.html
好,修改
RewriteRule ^/test/2_5/page.html /tt.html [L]
在站点的根文件夹中删除第一个/if,而不是在.conf文件中使用.htaccess。通常,最终的url应该是完整的,带有http://和domain,但这个也可以。如果你想按照规则做每件事,那么
RewriteRule ^/test/2_5/page.html$ http://example.com/tt.html [L]