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.

  • 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, 2013 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, 2013 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, 2013 at 18:03

2 Answers 2


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.


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:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.