Home Wordpress 301 redirect in htaccess
Reply: 1

Wordpress 301 redirect in htaccess

Robibob
1#
Robibob Published in 2018-01-10 05:44:55Z

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
Robibob
2#
Robibob Reply to 2018-01-12 19:12:48Z

I did find a solution myself:

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

# 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
You need to login account before you can post.

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

© 2016 Powered by mzan.com design MATCHINFO