[英]How To redirect Multiple Alternate URLs to a parent URL through HTACCESS
我的网站有这个上层网址
https://www.xyz.de
此外,还有其他URL可供访问,如下所示:
Alternate URL 1: http://xyz.de/index.php
Alternate URL 2: https://www.xyz-zvb.de/index.php
Alternate URL 3: http://www.xyz-zvb.de/index.php
Alternate URL 4: http://xyz-zvb.de/index.php
Alternate URL 5: www.xyz-zvb.de/index.php
但是,现在我想每次用户使用备用网站URL访问站点时,将所有这些URL重定向到主父站点URL,它将重定向到父主URL。
我已经尝试过如下操作,但是在这种情况下,只能重定向一个URL,我认为这不是推荐的方法。
Redirect 301 /contact.php http://example.com/contact-us.php
关于此任务有什么帮助吗?
您可以在网站根目录.htaccess中使用此规则:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} off [OR]
RewriteCond %{THE_REQUEST} \s/+index\.php[?/\s] [NC]
RewriteRule ^ https://www.xyz.de/ [L,NE,R=301]
用它:
# Permanent URL redirect
Redirect 301 /index.php https://www.xyz.de
如果是xyz-zvb.de或www.xyz-zvb.de
# Permanent URL
Redirect 301 / https://www.xyz.de
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.