我的旧网站有这样的链接:
http://domain.com/image.php?690
我想将其改为:
http://domain.com/old690
我尝试了很多不同的规则,fe . :
RewriteRule ^ image.php?( . )old $ 1 [L]
编辑:所有规则如下:
RewriteEngine On RewriteRule ^ admin /(.*)ninja-admin / $ 1 [L] RewriteRule ^ index.php $ - [L] RewriteCond%!-f RewriteCond%!-d RewriteRule . index.php [L] RewriteRule ^ image.php \?( . )old $ 1 [L]
什么是正确的RewriteRule,为什么?
2 回答
你这样做是颠倒的 .
把这段代码放在你的htaccess中
您的图像规则如下
它会将
/old123
(其中123
是一个或多个数字)的每个URL转发到image.php?123
编辑:如果你想禁止直接访问
image.php?xxx
那么你可以这样做我使用这个
http://example.com/old4444
转发到http://example.com/image.php?file=4444
.此外,浏览器将
http://example.com/old4444
保留在地址栏中 .