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 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2005
    Posts
    62
    Thanks
    1
    Thanked 0 Times in 0 Posts

    .htaccess rewrite url

    Hello. I have a quick question regarding url rewriting. I've been successful at using regular expressions in the past, but this one (though simple) has me stumped.

    I'd like to make links throughout the site look like this:

    http://www.indianasheep.com/membership

    However, the php file is actually located at:

    http://www.indianasheep.com/pages/membership.php

    Thus, a simple redirect is in order, but I'm unable to get the syntax correct. Here is what I currently have:

    RewriteRule ^([A-Za-z]+)?$ /pages/$1.php

    And the .htaccess file is located in the pages directory.

    Can anyone provide assistance?

    Thanks,

    Ryan

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    I'm thinking you need to store the .htaccess file in your base directory, but I'm no expert at mod rewrite.

  • #3
    New Coder
    Join Date
    Jan 2005
    Posts
    62
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks, that fixed the problem. But now I've got another url rewrite problem. After supplementing the last code, I attempted to do this on another page: www.rndpig.com. In this case, I can type www.rndpig.com/about into the address bar and it will take me to the correct page. The actual page address is www.rndpig.com/pages/about.php. However, when I changed links on the site to www.rndpig.com/about the links failed.

    What could be causing the difference in typing the address into the address bar and clicking on a link that goes to the same address?

    Any help would be appreciated.

    Thanks,

    Ryan


  •  

    Posting Permissions

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