php - How to create directory like urls for each page on a website -
i have content site spreads across multiple pages there 1 index.php file retrieves data database based on page no.
currently url direction has domainname.com/page/content.php?page=3
i have noticed, quite few sites have directory structure urls like:
domainname.com/page/3
i know how change domainname.com/page/?page=3
looking remove ?page
part.
how can this, without individually creating directory each page, content keeps growing, hence changes each page.
thanks
these sites use mod_rewrite "rewrite" on requested url using regular expression
edit:
rewriting this: domainname.com/page/3
to that: domainname.com/page/content.php?page=3
would in .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 made restriction var name letter either capital or small.
Comments
Post a Comment