php - Rewrite dynamic urls -
i have user.php file contains code different pages - account, data , home. accessed through dynamic url parameters so:
http://localhost/user.php?page=home http://localhost/user.php?page=account http://localhost/user.php?page=data
they work fine , happy how works. them displayed http://localhost/user/<thepagename>/
, preferably ?page=home
http://localhost/user/
.
i have tried few .htaccess rules web these either don't work, or require me go through user.php rewritten urls, messy , "ugly" having parameters in url (as in http://localhost/user.php/pagename/
).
i know rewrite not necessary in case working on sort of testing project grips practical uses variety of functions , practices.
thanks in advance.
enable mod_rewrite , .htaccess through httpd.conf
, put code in .htaccess
under document_root
directory:
options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on rewritebase / rewriterule ^user/?$ /user.php?page=home [l,qsa,nc] rewriterule ^user/(.+?)/?$ /user.php?page=$1 [l,qsa,nc,ne]
Comments
Post a Comment