Php 如何使用.htaccess重写单个URL

Php 如何使用.htaccess重写单个URL,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,我只需要重写一个特定的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 到 如何做到这一点 谢谢 Redirect /test/2_5/page.

我只需要重写一个特定的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

如何做到这一点

谢谢

Redirect /test/2_5/page.html /tt.html
好的,修改一下

RewriteRule ^/test/2_5/page.html /tt.html [L]
如果在站点的根文件夹(而不是.conf文件)中使用.htaccess,请首先删除/if。通常,最终的url应该是完整的,带有http://和domain,但这个也可以。如果你想按规则办事,那么

RewriteRule ^/test/2_5/page\.html$ http://example.com/tt.html [L]

我不想重写redirect@mwafi为什么?结果是一样的
RewriteRule ^/test/2_5/page\.html$ http://example.com/tt.html [L]