Redirecting old urls via .htaccess
Posted: 13 October 2008 04:53 PM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  284
Joined  08-11-2007

I looked through my sites error log as well as google’s webtools error log and noticed that a handful of my old urls from a pre-existing CMS are coming up as 404s. I’d like to be able to redirect these at least in a general way but I’m completely unfamiliar with .htacess rules.

My current .htaccess file looks like this:

RewriteEngine On

RewriteCond
%{REQUEST_FILENAME} !-f
RewriteCond
%{REQUEST_FILENAME} !-d
RewriteRule
^(.*)$ index.php\?/$1 [L]

RewriteCond
%{HTTP_HOST} ^mysite\.com
RewriteRule
(.*) http://www.mysite.com/$1 [R=301,L]

I have two scenarios I’d like to know how to redirect:

From a dynamic page to a static page:
http://mysite.com/category/{variable} to mysite.com/forums/

From a dynamic page to another dynamic page with the same variable:
http://www.mysite.com/blog/read/{variable} to http://www.mysite.com/articles/read/{variable}

These can all be 301 redirects. Thanks for any help you can provide.

 Signature 

EE 1.65 Build 10312008 |  Forum: 2.1.1 Build 20081028
ELITETRACK | HPCsport | AthleticLab

Profile
 
 
Posted: 14 October 2008 04:07 AM   [ Ignore ]   [ # 1 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  149
Joined  05-14-2008

Ok I’m not very awake this morning mostly because I spent most of yesterday doing .htaccess files and my brains a bit fried! But I think I should be able to help with this one or at least a point in the right direction

RewriteRule ^category/?(.*)$ http://mysite.com/forums/ [L,R=301]
RewriteRule ^/blog/read/?(.*)$ http://www.mysite.com/articles/read/$1 [L,R=301]

Let me know if that helps grin

Best Regards

Emily

 Signature 

Emily Griffiths | NuBlue Web Solutions | Lancaster UK

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64912 Total Logged-in Users: 28
Total Topics: 81864 Total Anonymous Users: 18
Total Replies: 440104 Total Guests: 188
Total Posts: 521968    
Members ( View Memberlist )
Newest Members:  bjmohrAqua193Bios Elementmjpoteetguimogranwelshmrcfthenetmonkeybenekwhobutsb