具有百分比的一个URL的Mod_rewrite规则

时间:2014-02-18 10:31:00

标签: php apache .htaccess mod-rewrite

我不明白。我有一个htacces文件,可以重定向单个URL。

示例:

Redirect 301 /upload/pdfs/2014/12345678.pdf /upload/documents/12345678.pdf

好的,到目前为止工作。

但现在我必须重定向此网址:

/ COM /汽车/细节/ 1234 / [DB%0A%0Alink] html的

为:

http://www.domain.de/Car-JohnDoe

我尝试了很多表达式:

Redirect 301 /com/cars/detail/1234/[DB%0A%0Alink].html http://www.domain.de/Car-JohnDoe
Redirect 301 /com/cars/detail/1234/([^0-9]*) http://www.domain.de/Car-JohnDoe
Redirect 301 /com/cars/detail/1234/([^0-9]*)$ http://www.domain.de/Car-JohnDoe
Redirect 301 /com/cars/detail/1234/(.*)$ http://www.domain.de/Car-JohnDoe
Redirect 301 /com/cars/detail/1234/(.*)$ http://www.domain.de/Car-JohnDoe
RedirectMatch 301 ^/com/cars/detail/1234/(.*)$ http://www.domain.de/Car-JohnDoe
Redirect 301 /com/cars/detail/1234/[DB\%0A\%0Alink].html http://www.domain.de/Car-JohnDoe

但一切都没有效果。 “1234”是一个ID,所以所有的东西都可以作为通配符/ placegolder。但实际上我只需要一个针对这个网址的规则。

我希望你明白我的意思(抱歉我的英语不好)......

祝福 八字

1 个答案:

答案 0 :(得分:0)

这应与/com/cars/detail/1234/[DB%0A%0Alink].html匹配并重定向到/Car-JohnDoe

RedirectMatch 301 "^/com/cars/detail/1234/\[DB\s+link\].html" /Car-JohnDoe

对于其他规则,请务必使用RedirectMatch代替Redirect

相关问题