I have a url similar to:
http://.../user.php?do=login
and with PHP I'd like to make it look like:
http://.../user/login/
How would I go about this? Most places seem to be talking about .htaccess, of which I don't have access to.
Thanks.
I have a url similar to:
http://.../user.php?do=login
and with PHP I'd like to make it look like:
http://.../user/login/
How would I go about this? Most places seem to be talking about .htaccess, of which I don't have access to.
Thanks.
htaccess rewrite for query string
create a .htaccess file and write
RewriteRule ^(.*)$ user.php?url=$1 [L,QSA]
As other people said, just use links like /index.php/nice/looking/url
.
The "index.php" in the middle of the URL might look a little strange, but I don't think it's possible to have it look better without .htaccess
Else, you could ask your hoster to redirect any URL to /index.php so that you can handle URL rewriting without having /index.php
in your URL.
Then you can just use a regex match to detect what file to include.
preg_match('@[/]{1}([a-zA-Z0-9]+)@', $_SERVER["PATH_INFO"], $matches)
($matches will contain all "parts" of the url in an array)
Be careful with including the files, use a whitelist so you're sure nobody would be able to load internal files.