简体   繁体   中英

htaccess redirect not working in same domain

I want to redirect https://xxx.xxxx.com/zzz to https://xxx.xxxx.com/zzz247 . I have tried this

Redirect 301 / https://xxx.xxxx.com/zzz247

So now when I try https://xxx.xxxx.com/zzz its take me into https://xxx.xxxx.com/zzz247zzz247zzz247zzz247zzz247zzz247zzz247....

How can I fix this issue? help please

What is required

I need enable only one URL which is https://xxx.xxxx.com/zzz247 even user type https://xxx.xxxx.com/zzz

Instead of Redirect directive use RedirectMatch with regex support:

RedirectMatch 301 ^/zzz/?$ /zzz247

Redirect appends current URI into redirected URI and since you're matching / that will match anything and cause a redirect loop.

Make sure to clear your browser cache before testing.


Using RewriteRule you can do this:

RewriteRule ^zzz/?$ /zzz247? [L,NC,R=301]

? at the end of the target URI is for stripping any query string.

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