php - Page id without '?' in URL -
i have seen websites different pages accessed via page id isn't passed through via method..
so this: http://www.website.com/sitefolder/pageid/ @ other websites see: http://www.website.com/index.php?id=12
i know different pages of example 1 stored in db , not in different folders suggest..
normally if have forward slash mean you're going through different folders..
can explain me how can create forward slash page id indicator without havering make hundreds of different folders different pages?
so 1 php page in 'sitefolder' adapts content page id or page name or url alias passed through url without using '?id=12' method.
you accomplish using .htaccess
rule mod_rewrite
enabled, so:
rewriteengine on rewriterule ^/([^/]+)$ index.php?id=$1
this rewrite example.com/12
example.com/index.php?id=12
.
edit: regex, broken down:
^
match start of line/
match slash([^/]+)
match , save first group of characters aren't slash$
match end of line
and in case of rewriterule
regex, "line" means after example.com
.
Comments
Post a Comment