.htaccess - htaccess - rewriterule help needed -
i having problem rewrite rules. have urls variables this: localhost/mysite/user.php?u=username
. want convert them this: localhost/mysite/user/username/
this have tried
rewriterule ^user/([a-za-z0-9-]+)/?$ /mysite/user.php?u=$1 [nc,l] # handle user page requests
but not working :(
/mysite/user.php
in htdocs folder (because in local environment)
if somehow url opened localhost/user.php?u=username
should redirect or change localhost/user/username/
, possible?
you can use code in /mysite/.htaccess
file:
options -multiviews rewriteengine on rewritebase /mysite/ rewritecond %{the_request} /user\.php\?u=([^\s&]+) [nc] rewriterule ^ user/%1/? [r=302,l,ne] rewritecond %{request_filename} !-f rewritecond %{the_request} \s/+(.*?)[^/][?\s] rewriterule [^/]$ %{request_uri}/ [l,r=301] rewriterule ^user/([^/.]+)/$ user.php?u=$1 [l,qsa,nc]
Comments
Post a Comment