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

Apache Web Server Forum

URL Rewriting for Images,movie news website.
I had thousands of webpages on images and movie news

Msg#: 4298204 posted 12:50 pm on Apr 15, 2011 (gmt 0)

I had different kind of categories to mysite.I will update my website everyday.I know one method to convert all dynamic to static urls by manually writing code for each page but its a tedious job.
I observed some sites belong to my niche having perfect static urls and also i observed that all urls are equal to the heading of the article or the gallary name.
so i am curious to know that is there any way to convert the heading of the page to url of the page in htaccess like

i used hxxt instead of http

Dynamic Url:hxxp://www.mysite.com/news_details.php?newsid=15
heading of the article title: is michael jackson still alive?
desired Static url :hxxp://www.mysite.com/is-michael-jackson-still-alive.html
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /news_details\.php\?newsid=15\ HTTP/
RewriteRule ^news_details\.php$ [mysite.com...] [R=301,L]
RewriteRule ^is-michael-jackson-still-alive.html$ /news_details.php?newsid=15 [L]

The following are my site dynamic categories

final image pages
other categories

I had about 10,000 pages in my site.which is the best method of converting from static url to dunamic urls in my case.whether i have supposed to goto the manual rewrite for all 10,000 pages or is there any shortcut to achive this.
If i suppose to add 10,000 codes in my htaccess i am planning the following code



WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

Msg#: 4298204 posted 1:07 pm on Apr 15, 2011 (gmt 0)

This type of question has been asked several times per week, every week for the last 8 years. As such there are a huge number of prior threads with example code and very detailed reasoning for how and why the code is as it is.

The most efficient way will likely be:
1. change all the links on your pages to point to the correct URLs that you want users to see and use. It is suggested that you include an ID number within the new URLs to make the look up much easier.
2. install a rewrite to capture requests for old URLs and internally rewrite to a special script that will examine the request and work out (by way of a database lookup) what the new URL is, and then issue an external 301 redirect to that new URL.
3. install a rewrite that captures requests for new URLs and internally rewrites the request to point to the correct folder and file inside the server to fetch the content.
4. Add a function to the script to check that requests for new URLs are exactly right i.e. that the text within the URL is correct for that ID number, and if it is not then to redirect to the correct URL.


Msg#: 4298204 posted 12:02 pm on Apr 19, 2011 (gmt 0)

Hello g1smd
Thanks for your reply,sorry to say that i am not an expert in this.

So can you please give me the sample codes


WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 4298204 posted 7:20 pm on Apr 25, 2011 (gmt 0)

Already posted many times. Please try a search and see our Apache Forum Library.


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