Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Possible Duplicate:
.htaccess Redirect Old Threads

We had quite a hefty news site which had very ugly urls from a custom cms. We have since relaunched and moved all the content over to Wordpress and have used "pretty permalinks".

We were also running a newsletter campaign throughout and would like to redirect all the ugly url's to the pretty one's. How can this be done? Can they be put in the htaccess file? We just want it so when the url is clicked in the newsletter it will redirect to the new url.

Here is an example of what we want:

We want this - http://www.domain.com/index.php?id=3&nid=91 to be redirected to this http://mediwales.com/this-is-my-pretty-permalink

What type of redirect's should they be?

UPDATE:

This is my current htaccess file in the root:

RewriteEngine on
RewriteRule ^([0-9A-Za-z]+)$ /index.php?page=$1 [L]
# 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
share|improve this question

marked as duplicate by paulmorriss, Su', John Conde Jul 29 '12 at 17:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

2 Answers 2

up vote 1 down vote accepted

Use .htaccess to redirect with the following code:

RewriteEngine on
RewriteRule ^([0-9A-Za-z]+)$ /index.php?page=$1 [L]
# 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
Redirect /index.php?id=3&nid=91 http://mediwales.com/this-is-my-pretty-permalink
share|improve this answer
    
Thanks. I've just updated my question with my current htaccess file. How can I incorporate the two? Don't want to take the site down by accident! –  Rob Jul 23 '12 at 15:48
    
Updated my comment –  Vince Pettit Jul 23 '12 at 16:11
add comment

U can use this .htaccess

RewriteEngine on
RewriteRule ^([0-9A-Za-z]+)$ /index.php?page=$1 [L]
# 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
Redirect /index.php?id=3&nid=91 http://mediwales.com/this-is-my-pretty-permalink

Problem is u have to add every redirect manually (See below) The .htaccess is the same as yours, except the

Redirect /index.php?id=3&nid=91 http://mediwales.com/this-is-my-pretty-permalink

The following would be my prefered way

Because you dont need the rewrite rule for every page. The way is to get pretty-permalink running on your old host. Goal is to have the same pretty-permalink on both domains, than u can easily use a 301 redirect and avoid duplicate content. Put this on your.htaccess on the old domain.

RewriteEngine on
RewriteRule ^(.*) http://mediwales.com/$1 [R=301,L]

If you type http://www.domain.com/this-is-my-pretty-permalink in your browser you will be redirected to http://mediwales.com/this-is-my-pretty-permalink

Depending on your cms and/or you are using the same page structure, then u dont need the pretty-permalinks on the old host. http://www.domain.com/index.php?id=3&nid=91 should route to http://mediwales.com/this-is-my-pretty-permalink

Hope this helps

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.