0
votes

I have a wordpress multisite installation with one site whose URL has changed from ppsdb.ppsri.org to guide.ppsri.org. I've updated the database to reflect this and the new URL works fine. But I'd like any visitors to the old URL to be redirected to the new one. I've tried adding 301 redirects to .htaccess but they don't seem to be working:

RewriteRule ^ppsdb.ppsri.org/(.*)$ guide.ppsri.org/$1 [R=301,NC,L]

Visiting ppsdb.ppsri.org just takes me to the registration for a new site in the network: http://ppsri.org/wp-signup.php?new=ppsdb

Here's my full .htaccess:

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

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

# redirect old Guide url traffic
RewriteRule ^ppsdb.ppsri.org/(.*)$ guide.ppsri.org/$1 [R=301,NC,L]

</IfModule>

# END WordPress

How can I get the old URL to forward to the new one?

1

1 Answers

1
votes

Update: I was able to get it working by adding the following to the beginning of my .htaccess (before everything else):

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ppsdb\.ppsri\.org$
RewriteRule ^(.*)$ http://guide.ppsri.org/$1 [R=301,L]
</IfModule>

So the full .htaccess is:

# redirect old Guide url traffic
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ppsdb\.ppsri\.org$
RewriteRule ^(.*)$ http://guide.ppsri.org/$1 [R=301,L]
</IfModule>

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

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

</IfModule>

# END WordPress