2017-04-03 33 views
1

當用戶鍵入以下網址如何創建htaccess的重定向

http://www.oldwebsite.de/schnitz_krippen.php 
http://www.oldwebsite/holzrohlinge.php 
http://www.oldwebsite/neuheiten.php 
http://www.oldwebsite/impressum.php 

我需要這些URL重定向到

http://www.newwebsite.de/impressum.php 

它怎麼可能與htaccess的?我不需要重定向整個網站。因爲有些舊網站的鏈接需要顯示。例如:http://www.oldwebsite/main.php

RewriteEngine on 
RewriteOptions inherit 
RewriteBase/

RewriteCond %{HTTP_HOST} ^www.oldwebsite.com$ [NC] 
RewriteRule ^(.*)$ http://www.newwebsite.com/impressum.php [L] 

回答

0

這將重定向所有到您的虛擬主機到新的網站網址電話:

RedirectMatch permanent ^(.*)$ http://www.newwebsite.com/impressum.php 

如果你想只有特定的URL重定向:

Redirect "/schnitz_krippen.php" "http://www.newwebsite.com/impressum.php" 
Redirect "/holzrohlinge.php" "http://www.newwebsite.com/impressum.php" 
Redirect "/neuheiten.php" "http://www.newwebsite.com/impressum.php" 
Redirect "/impressum.php" "http://www.newwebsite.com/impressum.php" 
+0

的r ewriteEngine在 RewriteBase/ RedirectMatch永久^(。*)$ http://www.newwebsite.com/impressum.php [L]'這是全格式? –

+0

雖然服務器htaccess的,我需要編輯newwebsite或oldwebsite? –

+0

你必須把那舊網站的'.htaccess'文件,並將該文件必須在其根文件夾 – gmc

0

我認爲這將有助於你

RewriteEngine on 
# Redirect to another domain: www.newwebsite.de. 
RewriteCond %{HTTPS} off 
RewriteCond %{HTTP_HOST} !^(www\.)?newwebsite\.de$ [NC] 
RewriteRule .* http://www.newwebsite.de%{REQUEST_URI} [R=301,L] 
+0

雖然服務器htaccess是否需要編輯newwebsite或oldwebsite? –

+0

這是從http重定向到https? – Lag

+0

您需要編輯舊的。 –