views:

51

answers:

2

Hi, I have a content site that spreads across multiple pages but there is only 1 index.php file which retrieves the data from the database based on the page no.

Currently the url direction has to be something like domainname.com/Page/content.php?page=3

I have noticed, quite a few sites have directory like structure for the urls like:

domainname.com/Page/3

I know how to change it to domainname.com/Page/?page=3 but I am looking to remove the ?page part.

How can I do this, without individually creating a directory for each page, the content keeps growing, hence changes for each page.

Thanks

+3  A: 

These sites use mod_rewrite to do a "rewrite" on the requested URL using a regular expression

EDIT:

rewriting this: domainname.com/Page/3

to that: domainname.com/Page/content.php?page=3

would look like this in the .htaccess file:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([a-zA-Z]*)/(.*)$ /content.php/$1/page=$2 [L]
</IfModule>
<IfModule !mod_rewrite.c>
    ErrorDocument 404 /error_with_mod_rewrite.html
</IfModule>

here i also made a restriction for the var name to be a letter either capital or small.

ITroubs
Thanks will check it out
Gaurav
A: 

ht access url rewriting is what you need.

Check this one

http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html

here its discussing about

converting

http://www.example.com/viewcatalog.asp?category=hats&amp;prodID=53

to

http://www.example.com/catalog/hats/53/

this is what you need too

Something useful

http://roshanbh.com.np/2008/03/url-rewriting-examples-htaccess.html

zod