在HTACCESS

时间:2017-08-09 06:41:09

标签: .htaccess redirect dns

好的,这里很多。我最近更改了域名,我需要重定向一些东西。首先..

的所有页面

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>

1 个答案:

答案 0 :(得分: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>