Forum Moderators: phranque

Message Too Old, No Replies

Redirect everything except wordpress

         

hrGustafE

8:10 am on Apr 24, 2012 (gmt 0)

10+ Year Member



Hi you all

New here but I've used the search function in this forum for some time. I have a tricky problem to solve.

I've recently moved a site to a new domain and installed WP on the old one.

The problem, which I thought was easy to solve but no no, is that I need every url on the old domain to be directed to the new domain except a selected list of urls (which are the WP-site, about 20 pages in all)

ie
www.olddomain.se
www.olddomain.se/contact
www.olddomain.se/work
and so forth (a specified list of urls) should be left intact. And of course all the WP stuff needed to have the site working.
The rest should be redirected to
www.newdomain.se/whatever/you/type [R=301]

Is this doable? I begin to doubt it I must say. I have had no success whatsoever so far. But it might just be my limited knowledge of mod_rewrite that is keeping me from solving this...

Thanks for any help on this!

hrGustafE

8:24 am on Apr 24, 2012 (gmt 0)

10+ Year Member



I could add that what I've tried so far is
along the lines of


RewriteEngine On
RewriteBase /

# no redirect if you enter 'www.olddomain.se'
# RewriteCond %{REQUEST_URI} !/$ [NC]

# no redirect if you try to access one of the following pages
RewriteCond %{REQUEST_URI} !^/produkter [NC]
RewriteCond %{REQUEST_URI} !^/kontakt [NC]
#this one below I am uncertain on how to write but what I want is to filter out all WP stuff like wp-admin, wp-content
RewriteCond %{REQUEST_URI} !^/wp.* [NC]

#redirect everything else to the new domain
RewriteRule ^(.*)$ http://www.newdomain.se/$1 [NC]

#and then let WP do it's magic

# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress