簡體   English   中英

具有百分比的一個URL的Mod_rewrite規則

[英]Mod_rewrite rule for one URL with percent

我不明白 我有一個用於重定向單個URL的htacces文件。

例:

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

好的,到目前為止。

但是現在我必須重定向此URL:

/com/cars/detail/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,因此,該命令之后的所有內容都將是通配符/占位符。 但是實際上我只需要針對該單個URL的規則。

我希望你能理解我的意思(對不起我的英語不好)...

祝福巴茲

這應該可以匹配/com/cars/detail/1234/[DB%0A%0Alink].html並重定向到/Car-JohnDoe

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

對於其他規則,還請確保使用RedirectMatch而不是Redirect

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM