: What is the htaccess code for a clean URL for a user profile page? I have tried code given on under topic clean URLs using .htaccess, but it is nor working on my website. Actually I am
I have tried code given on under topic clean URLs using .htaccess, but it is nor working on my website.
Actually I am getting static content, but not getting parameters (dynamic content.) My .htaccess code is
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^user/([^/]+) /user.php?u=
My PHP file (user.php) is:
<?php
echo "ABC";
echo $_GET['u'];
?>
My URL is:
example.com/simran/user/jack
(getting static contents , but not parameters)
More posts by @Cody1181609
1 Comments
Sorted by latest first Latest Oldest Best
Easiest way is to Change:
RewriteRule ^user/([^/]+) /user.php?u=
to:
RewriteRule ^simran/user/([^/]+) /user.php?u= [L]
or for more flexibility you can use:
RewriteRule ^(.*)/user/([^/]+) /user.php?u= [L]
That should make these URL's work
example.com/any1user/user/jack
example.com/simran/user/jack
example.com/user/jack
I changed to because now points to contents before /user and you're interested in contents after /user. The .* means anything including nothing and punctuation.
In all cases, I always recommend suffixing a rule with an L in square brackets because it means don't process any further rules in the list after the rule is processed.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.