Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

URL Rewriting for Images,movie news website.

I had thousands of webpages on images and movie news

12:50 pm on Apr 15, 2011 (gmt 0)

New User

5+ Year Member

joined:Mar 23, 2011
votes: 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
1:07 pm on Apr 15, 2011 (gmt 0)

Senior Member

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

joined:July 3, 2002
votes: 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.
12:02 pm on Apr 19, 2011 (gmt 0)

New User

5+ Year Member

joined:Mar 23, 2011
votes: 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
7:20 pm on Apr 25, 2011 (gmt 0)

Senior Member

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

joined:Mar 31, 2002
votes: 0

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