What would be the best way to organize a url structure in your website?

I would like to know what would be the steps to take and go ahead and organize your code as well?

All in a way for production server and good for the SEO?

can you clarify? Are you talking about file structure, which your title alludes to. Or do you mean the code in the files?

I agree with phw57, mod_rewrite is what you need to use. For example, the two URLs are identical:


This tool may help as well:


If you’re wanting to change access to

Then you will require mod_rewrite techniques.

These techniques are not setup with PHP code, but are instead done via your server setup.
The most you will need to do in your PHP code is to update the web page links.

The Apache Configuration forum is the best place to get advice about this.

They even have a sticky thread called mod_rewrite Resources and articles such as [url=“http://articles.sitepoint.com/article/apache-mod_rewrite-examples”]Learn Apache mod_rewrite: 13 Real-world Examples

@rguy84 I mean both, The code in the file is what I am missing after @pmw57 and @inclick explanation on friendly urls and update the web page links as well…

I will those techniques the mod_rewrite technique and give it a try.

thank you very much.

This is the .htaccess code I used for PatchSales:

RewriteEngine On
RewriteRule ^category/([^/])/([^/])/([^/])\.html$ /index.php?pageid=itemview&category=$1&page=$2&pagetitle=$3 [L]
RewriteRule ^patch/([^/]
)/([^/]*)\.html$ /index.php?pageid=itemviewdetail&detail=$1&pagetitle=$2 [L]

Thank you inclick, but I feel that this belongs much more appropriately in the Apache Configuration forum.

People can also find there the article called Learn Apache mod_rewrite: 13 Real-world Examples from which they can match them up to their own requirements.

You can also opt to make your life easy and decode the URL within the application. That is the path I always choose besides rewriting everything to the application entry point. That way if certain routes require special treatment your not left to hack the .htaccess file.


Do you have any reference that shows how to re-write the url within the application?

I was in the mod_rewrite sitepoint tutorial and didn find the second line below

#LoadModule rewrite_module modules/mod_rewrite.so
#AddModule mod_rewrite.c

in the httpd.conf file.

what could be done in that place?

You will obtain better answers to this by asking this in the Apache Configuration forum.

With path info supported the simplest solution is to explode everything following the entry script by /.

$arrRequestArgs = isset($_SERVER['PATH_INFO'])?explode('/',trim($_SERVER['PATH_INFO'],'/')):array();
echo '<pre>',print_r($arrRequestArgs),'</pre>';

So this url: index.php/Product/My-Products-Name/

Would decode to: [0=>Product,1=>My-Products-Name]

Thank you guys.