简体   繁体   中英

Mod_rewrite rule for one URL with percent

I don't get it. I have a htacces-file for single URLs to be redirected.

example:

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

Ok, works so far.

But now I have to redirect this URL:

/com/cars/detail/1234/[DB%0A%0Alink].html

to:

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

I've tried a lot of expressions like:

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

But nothing worked at all. The "1234" is an ID, so everything that comes afer that coul be a wildcard/placegolder. But actually I need a rule only for this single URL.

I hope you understand what I mean (sorry for my bad english)...

Best wishes Bazi

This should work to match /com/cars/detail/1234/[DB%0A%0Alink].html and redirect to /Car-JohnDoe :

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

For other rules also make sure to use RedirectMatch instead of Redirect

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM