2017-08-18 39 views
0

多個備用網址重定向到父URL我有這樣的家長網址爲我的網站如何通過.htaccess的

https://www.günstiger-reisen.de 

而且有從那裏我的網站能夠像以下訪問是備用網址太:

Alternate URL 1: http://günstiger-reisen.de/index.php 
Alternate URL 2: https://www.xn--gnstiger-reisen-zvb.de/index.php 
Alternate URL 3: http://www.xn--gnstiger-reisen-zvb.de/index.php 
Alternate URL 4: http://xn--gnstiger-reisen-zvb.de/index.php 
Alternate URL 5: www.xn--gnstiger-reisen-zvb.de/index.php 

但是現在我想將所有這些網址重定向到主要父網站的URL,每次用戶訪問該網站時使用備用網站的網址,它將重定向到父主網址。

我已經嘗試過,但在這種情況下,只有一個URL可以重定向,我認爲這不是一個提供的方式來做到這一點。

Redirect 301 /contact.php http://example.com/contact-us.php 

有關此任務的任何幫助?

回答

0

使用它:

# Permanent URL redirect 
Redirect 301 /index.php https://www.günstiger-reisen.de 

如果xn--gnstiger-reisen-zvb.de或www.xn--gnstiger-reisen-zvb.de

# Permanent URL 
Redirect 301/https://www.günstiger-reisen.de 
+0

那其他領域,如果有人進入: https://www.xn--gnstiger-reisen-zvb.de 或 www.xn--gnstiger-reisen-zvb.de – Shoaib

+0

只需嘗試一下,將其添加到htaccess文件中@Shoaib –

+0

檢查更新後的代碼@Shoaib –

1

您可以使用此規則在你的站點根目錄的.htaccess:

RewriteEngine On 

RewriteCond %{HTTP_HOST} !^www\. [NC,OR] 
RewriteCond %{HTTPS} off [OR] 
RewriteCond %{THE_REQUEST} \s/+index\.php[?/\s] [NC] 
RewriteRule^https://www.günstiger-reisen.de/ [L,NE,R=301] 
+1

用'[OR]'爲www。我認爲這次是好的;-) – Croises

+1

有這麼多微妙之處,很難看到它們全部 – Croises