Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Aug 2009
    Location
    in .........
    Posts
    260
    Thanks
    183
    Thanked 0 Times in 0 Posts

    Need help in one of .htaccess commands

    I want the user to could see the url of his profile page of the site in this way "http://www.mysite/username"
    rather than
    "http://www.mysite/profile.php?id="

    and for that I used this command in .htaccess :

    RewriteEngine On
    RewriteRule ^([^/]*)\.$ /profile.php?id=$1&n=$a [L]

    but the problem with this is I have to add "." in the end of the username to be like this :
    "http://www.mysite/username."
    and I want it to be like this without the "." :
    "http://www.mysite/username"

    hope if any one can help

  • #2
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Should have post this in the apache forum

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Moving from PHP to apache configurations.
    Your rule specifies the .: RewriteRule ^([^/]*)\.$
    Remove the \. if you want to go without it. If you want it optional, add \.? instead.

  • Users who have thanked Fou-Lu for this post:

    Mido™ (12-12-2011)

  • #4
    Regular Coder
    Join Date
    Aug 2009
    Location
    in .........
    Posts
    260
    Thanks
    183
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    Moving from PHP to apache configurations.
    Your rule specifies the .: RewriteRule ^([^/]*)\.$
    Remove the \. if you want to go without it. If you want it optional, add \.? instead.
    Thanks but it didn't work and gave me error "500 Internal Server Error"

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    I'm not sure if you can match [^/] by itself like this. Refine your pattern to a more specific ruleset and try again.

  • Users who have thanked Fou-Lu for this post:

    Mido™ (12-12-2011)

  • #6
    Regular Coder
    Join Date
    Aug 2009
    Location
    in .........
    Posts
    260
    Thanks
    183
    Thanked 0 Times in 0 Posts
    I tried but it didn't work, hope if there is a solution for it.

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    So what is the match you are currently using?

  • #8
    Regular Coder
    Join Date
    Aug 2009
    Location
    in .........
    Posts
    260
    Thanks
    183
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    So what is the match you are currently using?
    I don't know what's you mean exactly, but I use this ^([^/]*)\.$ to get it characters or numbers after / and with "." in the end.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •