Redirect Visitors to new url but exclude images an

2019-02-20 14:15发布

问题:

I use self hosted wordpress and wish to redirect visitors from fashionbeautyetc.com to corresponding page/post on fayekent.co.uk. I wish to exclude the redirect being applied to images and the WP dashboard (wp-admin) what code should I place in htaccess

the code already in there is below:

SuPHP_ConfigPath /var/sites/f/fashionbeautyetc.com/public_html

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress   

回答1:

Add this before # BEGIN WordPress:

RewriteCond %{HTTP_HOST} ^(www\.)?fashionbeautyetc\.com$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g|png|gif|ico)$ [NC]
RewriteCond %{REQUEST_URI} !wp-admin
RewriteRule ^(.*)$ http://fayekent.co.uk/$1 [L,R=301]