Fadzy
Fadzy

Reputation: 37

batch .htaccess 301 redirect

I'm moving servers and cleaning up the url's a bit at the same time.

current urls are:

secure.mydomain.com/onlinestore/product.php?productid=12345

changing it to:

mydomain.com/product.php?productid=12345

wondering if I can do something in htaccess so if someone clicks an old link/bookmark they get redirected to the new page.

Not worried about making the dynamic part be SEO friendly just yet.

Upvotes: 1

Views: 395

Answers (1)

Michael Berkowski
Michael Berkowski

Reputation: 270657

Try this. It forces a redirect with a "moved permanently" header.

RewriteEngine On
RewriteCond %{HTTP_HOST} secure\.mydomain\.com
RewriteRule onlinestore/product\.php http://mydomain.com/product.php [L,R=301,QSA]

Edit was missing some / in the RewriteCond Edit2 Redirect wasn't going to the correct domain

Upvotes: 2

Related Questions