php - URL rewrite with .htaccess for login and profile system -
i have website url localhost/project/profile.php?user=username
and trying url this: localhost/project/username
the able rid of .php
using following code:
options +followsymlinks -multiviews rewriteengine on rewritebase / rewritecond %{the_request} ^[a-z]{3,}\s([^.]+)\.php [nc] rewriterule ^ %1 [r,l,nc] rewritecond %{request_filename}.php -f rewriterule ^ %{request_uri}.php [l]
but not need right now. here code meant changing url - got off of thread.
options followsymlinks rewriteengine on rewritebase / rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ /index.php?user=$1 [l,qsa]
but doesn't work.
i need able go url: localhost/project/username
, registers original url localhost/project/profile.php?user=username
** answer **
thanks howlin
rewriteengine on rewritecond %{the_request} ^(get|post)\ /project/profile\.php\?user=(.*)\ http rewriterule ^ /project/%2\? [r=301,l] rewritecond %{query_string} !user= rewriterule ^(.*)$ /project/profile.php?user=$1 [l]
this should work:
rewriteengine on rewritecond %{the_request} ^(get|post)\ /project/profile\.php\?user=(.*)\ http rewriterule ^ /project/%2\? [r=301,l] rewritecond %{query_string} !user= rewriterule ^project/(.*)$ /project/profile.php?user=$1 [l]
the above change project/profile.php?user=username
project/username
, load information project/profile.php?user=username
page
edit:
rewriteengine on rewritecond %{the_request} ^(get|post)\ /project/profile\.php\?user=(.*)\ http rewriterule ^ /project/%2\? [r=301,l] rewritecond %{query_string} !user= rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^(.*)$ /project/profile.php?user=$1 [l]
Comments
Post a Comment