Redirect and RewriteRule

Using mod_rewrite to handle various content issues

Redirect and RewriteRule

Postby Bangkok Bob » Mon Jan 08, 2007 7:46 pm

Hi,

I have a website migrating from static pages to dynamic pages using CMS.

I tried to use Redirect 301 to move content pages from old location to new location:
Code: Select all
Redirect permanent /mydirectory/mypage.shtml http://www.mysite.com/mydirectory/mynewpage-lxx.html


But I get a query string appended to the new URL which I guess is coming from the CMS:
Code: Select all
http://www.mysite.com/mydirectory/mynewpage-lxx.html?name=mydirectory/mypage.


So I think I must use RewriteRule:
Code: Select all
# enable mod_rewrite
Options +FollowSymLinks
RewriteEngine on
#
RewriteRule ^/mydirectory/mypage.shtml$ /mydirectory/mynewpage-lxx.html [R=301,L]

But this does not do anything. The old URL displays in the browser with a "page not found" generated by the CMS. Maybe I need a RewriteCond but I am not sure.

I would appreciate any help and advice to get this squared away.

Best regards,
Bangkok Bob
Bangkok Bob
 
Posts: 2
Joined: Mon Jan 08, 2007 7:20 pm

Postby richardk » Tue Jan 09, 2007 9:43 am

Try
Code: Select all
Redirect 301 /mydirectory/mypage.shtml http://www.mysite.com/mydirectory/mynewpage-lxx.html?


Then
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^mydirectory/mypage\.shtml$ /mydirectory/mynewpage-lxx.html? [R=301,L]


The ? at the end should stop the query string being appended.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Bangkok Bob » Tue Jan 09, 2007 2:11 pm

Hi richardk,

Many thanks for your solutions.

The first one, Redirect 301, works for me as the unwanted query string is no longer appended.

Best regards,
Bangkok Bob
Bangkok Bob
 
Posts: 2
Joined: Mon Jan 08, 2007 7:20 pm


Return to Content

Who is online

Users browsing this forum: No registered users and 13 guests

cron