Home Wordpress 301 redirect in htaccess
Reply: 0

Wordpress 301 redirect in htaccess

user810
1#
user810 Published in June 21, 2018, 8:43 am

Where to place rewrite conditions in .htaccess so Wordpress won't overwrite them time to time? And should it be placed before or after WP part? It should work for Google Analytics redundant hostnames.

These two lines should be placed outside WP part:

RewriteCond %{HTTP_HOST} ^old.com [NC]
RewriteRule ^(.*)$ http://www.new.com/$1 [L,R=301]

This works perfect but gets overwritten by WP:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^old.com [NC]
RewriteRule ^(.*)$ http://www.new.com/$1 [L,R=301]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.538715 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO