homepage Welcome to WebmasterWorld Guest from 54.197.130.16
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
htaccess redirect old to new
redirect old ids to new with slug
quitano




msg:4666087
 1:23 pm on Apr 26, 2014 (gmt 0)

I have general knowledge of htaccess. I can rewrite old urls to new...etc. I rebuilt the site and have new URLs with slug etc.. something i did not have before. I have about 4000 urls indexed by search engines.

These current URLs are like so:
exmaple.com/records.php?id=44

My new site URLs are like so:
exmaple.com/record-44-name-of-record

I can redirect each one individually with success with the following code in htaccess:

RewriteCond %{QUERY_STRING} id=44
RewriteRule ^records\.php /record-44-name-of-record? [R=301]

"name-of-record" is from MYSQL DB that i slug in the PHP script.

While the above works perfect. I don't want to manually write 4000 urls in my htaccess. I've tried many different ways based off of what i search here and google without luck.

Thanks for the help. I know that this may have been asked a lot here and I've tried many different ways w/o success.

 

phranque




msg:4666114
 4:29 pm on Apr 26, 2014 (gmt 0)

Internally rewrite those request patterns to a PHP script which does the database lookup and responds with a 301 status code and a Location: header.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved