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 10 of 10
  1. #1
    New Coder
    Join Date
    Aug 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    user friendly URL, how ? :(

    Hello
    I m using a script which is in php+smarty method.
    so when it recives $_GET command like " ?page=home " it loads " home.tpl " .

    now I wanna use something user freindly URl for this script.for ex :

    www.example.com/?page=test ==> www.example.com/test/

    what should I do

    Thanks for ur great help.

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    You usually use Apache's mod_rewrite via the .htaccess file. Here is a decent cheat sheet. If you have never used mod_rewrite it can be a little confusing, but there are a lot of guides out there you can search for, and if you get stuck there are a lot of knowledgeable people on this forum. It usually helps if you know regular expression syntax, but it's not required.

  • #3
    New Coder
    Join Date
    Aug 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I tried this 1 , but doeant work

    PHP Code:
    RewriteEngine on
    RewriteRule 
    ^([A-Za-z0-9-]+)/?$ index.php?page=$1  [L

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    Quote Originally Posted by esytiger View Post
    I tried this 1 , but doeant work
    What exactly doesn't work? Make sure the .htaccess file is in your document root. Also, try replacing [L] with [QSA,L].

  • #5
    New Coder
    Join Date
    Aug 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I mean it doesnt change the url. the URl remains as its original

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,849
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #7
    New Coder
    Join Date
    Aug 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    mod_rewrite is enabled here.
    it was my fault, I Thought if I use ?page=test it should redirect to /test/
    but I tried /test/ and it loads the ?page=test, its fine , but

    1- non of the links wrok in pages
    I mean non of the images load, or the CSS link doesnt work, and pages are just text
    the source links are changed like :
    http://domain/images/top.gif is changed to http://domain/faq/images/top.gif
    it means that I should creat a folder for each page ?

    2- after the user logins , in member area , if we try for example "/profile/" which has to show " ?page=profile" the script, logs out from member area, the pages inside member area, after login , are not accessable

    thanks
    Last edited by esytiger; 03-05-2008 at 04:39 PM.

  • #8
    Regular Coder
    Join Date
    Oct 2005
    Location
    Surrey, England
    Posts
    286
    Thanks
    2
    Thanked 2 Times in 2 Posts
    1) http://www.w3schools.com/tags/tag_base.asp
    Code:
    <base href="http://www.domain.com/" />
    Place that in the header and it will dodge the relative file paths. (obviously change it to your domain though)

    2) No idea. Provide some code?
    Daniel Warner
    - - - - - - - - - -
    GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.

  • #9
    Regular Coder croatiankid's Avatar
    Join Date
    Jan 2006
    Posts
    665
    Thanks
    1
    Thanked 12 Times in 12 Posts
    I'd read this article to get a better understanding of mod rewrite.

  • #10
    New Coder
    Join Date
    Aug 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks all
    best forum around


  •  

    Posting Permissions

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