I want to redirect my 301 URLs on some other URls. Below is the cases:
xyz.com/html/german = xyz.com/de
xyz.com/german = xyz.com/de
one more case :
xyz.com/html/german/subpage.html = xyz.com/de/subpage
Any one help on this?
I tried with Regex but it is not working:
Here is what I have tried :
RewriteRule ^/de/([^/.]+)$ html/german/$1 [L]
Your rule is actually doing reverse. Try these redirect rules:
RedirectMatch 301 ^/(html/)?german/?$ /de
RedirectMatch 301 ^/(?:html/)?german/([^.]+)(?:\.html)?$ /de/$1
Remove the leading slash from Rewrite pattern :
Try:
RewriteRule ^de/?$ html/german/ [NC,L]
RewriteRule ^de/([^/.]+)/?$ html/german/$1 [NC,L]
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.