apache - Treat file name as PHP GET -


i have profiles on test website setup viewed in format:

example.com/profile.php?u=username 

i use format:

example.com/profile/username 

how treat username variable in php, rather file?

you need use apache mod_rewrite.

create file named .htaccess on root of website , add following:

rewriteengine on rewriterule ^/profile/(.*)$ /profile.php?u=$1 [qsa,l] 

now, if navigate :

example.com/profile/usertest 

apache send variable usertest profile.php?u=usertest


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -