Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on a site that hosts classified listings. I'm currently using hash/query params and Ajax to display content.

Example: www.site.com/viewpost?id=34089

We are now interested in making unique URLs with more info for SEO.

Example: www.site.com/title/category/stuff/info-0037843.htm

How do I go about getting from example 1 to example 2?

Are these URLs actual pages on the server? Or is there some rewrite trick to pull this off? I've seen this done on several other sites, but I'm not aware of how it's done.

The site is on a shared hosting environment with a LAMP setup.

share|improve this question

migrated from stackoverflow.com Jul 15 '13 at 13:01

This question came from our site for professional and enthusiast programmers.

You would have to get the content of the URL on the first request and redirect after you can construct the URL the way you want. – PeeHaa Jul 11 '13 at 17:57
It's definitely a rewrite rule. Part of the URL string will be the unique identifier, and a regular expression will filter out that part from all the SEO spider food. – Set Sail Media Jul 11 '13 at 17:58
As how exactly this is done depends on the underlying server/scripting technology it would be helpful to mention these (eg in a servlet environment you'll most likely use a servlet controller but for other server type some kind of rewrite logic is more appropriate) – fvu Jul 11 '13 at 18:03

What I have done in the past is use mod_rewrite to put all requests to an index.php. Then use the $_SERVER variables to parse the URL requested and serve relevant content.

share|improve this answer

There are a lot of ways to approach this, depending on what you are using as your backend.

Let me first start off my saying, unless users are typing URLs to get content, URL SEO mostly fake and doesn't effect page ranking:


But, if you still want to do it; using rewrites makes the most sense:


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.