Results 1 to 3 of 3

Thread: .htaccess & php files - mod_rewrite

Hybrid View

  1. #1
    Join Date
    Jul 2010
    Birmingham, UK

    .htaccess & php files - mod_rewrite

    i'm not sure if this is the right place for this, but hopefully someone will know what i'm looking for. i have been trying to clean up all the ugly urls all over my site, and i have come across a lot of material about editing/creating a .htaccess file for cluft-free addresses. i thought i would start with the simple, straight-forward pages just to get a handle on what i'm doing, but even these are not working the way i want.

    the problem seems to be that php files don't want to rewrite at all, and i get a 404 instead. if i do something like this:

    Options +FollowSymlinks
    RewriteBase /
    RewriteEngine on
    RewriteRule ^signup/?$ /signup.php
    RewriteRule ^contact/?$ /contact.html

    the contact.html rewrite works perfectly, but the signup.php gives me the error. it seems to me that there is either a setting somewhere or something in the code that i'm just not getting right, though everything i've read pretty much sites this method for achieving the rewrite to both .html and .php files. i have been reading for hours now, and i just cannot find anything that touches the problem. i really don't know much at all about what i'm doing, so any help would be appreciated.

  2. #2
    Join Date
    May 2010
    Manila, Philippines
    Hhhmmm.. I'm not expert in .htaccess but let me help you. First, do you intend to redirect the two pages into another page? if so, on what pages?

    We often use .htaccess whenever we made changes on directory or page name so that when the user access the page again with the same old name or directory the htaccess will redirect the user to another page/directory instead of getting errors such as 404.

  3. #3
    Join Date
    Jul 2010
    Birmingham, UK


    thanks for the reply. i have figured out a sort of workaround, though i still cannot figure out the source of the problem. my two goals for this mod_rewrite were to 1) remove the .php from the end of the url, and 2) shorten really long urls to something short and easy to remember:

    root/folder01/folder02/folder03/file.php => root/nickname (without extension)

    it is not a redirect, just telling apache to look for "root/nickname" and translating it back to "root/folder01/folder02/folder03/file.php" or whatever. that's the way i understand it anyway, but i could be wrong.

    anyway, it seems that something in "^signup/?$ /signup.php" or the actual code in signup.php itself was causing an error. i'm still not sure what though. in the course of trying different things, i discovered that other nicknames worked fine - "signup/" in particular seemed to cause the most grief.

    so i have mapped out all of my directory structure now, and all that the user sees are short, catchy urls.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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