2017-08-09 81 views
0

好的,這裏相當多。我最近更改了域名,我需要重定向相當多的東西。首先..在HTACCESS中將某個URL重定向到另一個URL

http://helloarchie.blue(舊域)的所有頁面

需要重定向到

http://helloarchie.co(新域)。

到目前爲止只有通過cPanel設置的主頁重定向。

我還需要所有圖像重定向這個網址:

http://kaye.at/img/

http://helloarchie.co/img/

這裏是我的htaccess目前。

Options -indexes 

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/

# Allow any files or directories that exist to be displayed directly 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

# Rewrite all other URLs to index.php/URL 
RewriteRule ^(.*)$ index.php?/$1 [L] 

# RewriteCond %{HTTP_HOST} ^(www\.)?kaye\.at$ 
RewriteRule ^(.+\.png|gif|pdf|jpg|doc)$ http://helloarchie.co/$1 [NC,L,R] 
</IfModule> 

<IfModule !mod_rewrite.c> 
ErrorDocument 404 index.php 
</IfModule> 

RewriteCond %{HTTP_HOST} ^www\.helloarchie\.co [NC] 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$ 
RewriteRule ^(.*)$ http://helloarchie.co/$1 [L,R=301] 

<Files 403.shtml> 
order allow,deny 
allow from all 
</Files> 
+0

的RewriteCond%{HTTP_HOST} ^(WWW \)凱\ $ .AT重寫規則 ^(+ \ PNG | GIF | PDF | jpg | doc)$ http://helloarchie.co/$1 [NC,L,R]只重定向png,git,pdf,jpg,doc文件。那是你要的嗎 ?什麼是問題? – wargre

+0

我已經澄清我的查詢更好一點(希望)。 –

+0

RewriteCond%{HTTP_HOST}^www \ .helloarchie \ .co [NC] ==>應該是RewriteCond%{HTTP_HOST}^www \ .helloarchie \ .blue [NC] – wargre

回答

0

您需要重新排序規則:?。

<Files 403.shtml> 
order allow,deny 
allow from all 
</Files> 

Options -indexes 

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/

RewriteCond %{HTTP_HOST} ^(?:www\.)?helloarchie\.blue$ [NC] 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ [NC] 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ [NC] 
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[\w-]+$ [NC] 
RewriteRule^http://helloarchie.co%{REQUEST_URI} [L,R=301,NE] 

RewriteCond %{HTTP_HOST} ^(www\.)?kaye\.at$ 
RewriteRule ^(.+\.png|gif|pdf|jpe?g|doc)$ http://helloarchie.co/$1 [NC,L,R=301] 

# Allow any files or directories that exist to be displayed directly 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
# Rewrite all other URLs to index.php/URL 
RewriteRule ^(.*)$ index.php?/$1 [L,QSA] 

</IfModule> 

<IfModule !mod_rewrite.c> 
ErrorDocument 404 index.php 
</IfModule> 
+0

@KayeHuett:這對你有幫助嗎? – anubhava

相關問題