简体   繁体   English

htaccess重定向不在同一个域中工作

[英]htaccess redirect not working in same domain

I want to redirect https://xxx.xxxx.com/zzz to https://xxx.xxxx.com/zzz247 . 我想将https://xxx.xxxx.com/zzz重定向到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.... 所以,现在当我尝试https://xxx.xxxx.com/zzz时, https://xxx.xxxx.com/zzz带我进入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 我只需启用一个URL,即https://xxx.xxxx.com/zzz247即使是用户类型https://xxx.xxxx.com/zzz

Instead of Redirect directive use RedirectMatch with regex support: 而不是Redirect指令使用RedirectMatch和正则表达式支持:

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. Redirect将当前URI附加到重定向的URI中,因为您匹配/将匹配任何内容并导致重定向循环。

Make sure to clear your browser cache before testing. 确保在测试前清除浏览器缓存。


Using RewriteRule you can do this: 使用RewriteRule可以执行以下操作:

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

? at the end of the target URI is for stripping any query string. 在目标URI的末尾用于剥离任何查询字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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