Results 1 to 9 of 9

Thread: htaccess mod_rewrite

  1. #1
    Join Date
    Mar 2009
    Posts
    42
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Default htaccess mod_rewrite

    Hi,

    Can anyone help; I have urls with .php extensions.

    http://domain.com/our_profile.php

    Is there a way to remove the .php file extensions using .htaccess?

    http://domain.com/our_profile/

    Many thanks for any help.
    Last edited by john0611; 01-10-2010 at 05:42 PM.

  2. #2
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Code:
    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php

  3. #3
    Join Date
    Mar 2009
    Posts
    42
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Default

    Hi, thanks for quick reply,

    I am getting a 500 Internal Server Error, I am relatively new to .htaccess I am not quiet sure whats going on. I know how to initiated the htaccess file but not sure why the 500 error?

    Thanks again for your reply.

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    You're getting the 500 error because this option isn't enabled in http.conf. If you're doing this locally, find http.conf in the parent directory of your www folder, if your doing this online, and the cpanel isn't giving you an option to modify it, contact your host.

    But, if it does, find this line:
    Code:
    #LoadModule rewrite_module modules/mod_rewrite.so
    And remove the #.

    Good luck
    Jeremy | jfein.net

  5. #5
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Make sure you put:

    domain.com/myfilehere

    And not:

    domain.com/myfilehere/

    The last / will give you the error.

  6. The Following User Says Thank You to Schmoopy For This Useful Post:

    john0611 (01-10-2010)

  7. #6
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    You may want to fix that for him - its not common that people don't put the '/'.
    Jeremy | jfein.net

  8. The Following User Says Thank You to Nile For This Useful Post:

    john0611 (01-10-2010)

  9. #7
    Join Date
    Mar 2009
    Posts
    42
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Default

    Cracked it!

    Thanks for all the help guys!

  10. #8
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Glad to help!
    Jeremy | jfein.net

  11. #9
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Having said that, does anyone have any idea why the trailing / brings up an internal error, and have any way of fixing it?

    Cheers.

Bookmarks

Posting Permissions

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