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
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts

    No File Extensions on URLs

    How do you remove them? I remove them with the following code (using mod_rewrite):

    Code:
    ^(somepage|someotherpage)/?$ /$1\.php
    But, I've heard there's a more efficient way to do it. What is it?

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    you method looks ok to me,

    but there are a few ways to do this;

    PHP Code:
    RewriteEngine on
    RewriteCond 
    %{REQUEST_FILENAME} !-d
    RewriteCond 
    %{REQUEST_FILENAME}.html -f
    RewriteRule 
    ^(.*)$ $1.html 
    PHP Code:
    RewriteEngine On
    RewriteCond 
    %{REQUEST_FILENAME} !-f
    RewriteCond 
    %{REQUEST_FILENAME} !-d
    RewriteRule 
    ^(.*)$ index.php?q=$[L,QSA

  • #3
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts
    Would you mind explaining each line to me? I don't mean to be an annoyance, but I've only ever done a couple of things on .htaccess, so it's still very new to me.


  •  

    Posting Permissions

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