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 9 of 9
  1. #1
    Regular Coder
    Join Date
    Aug 2005
    Posts
    257
    Thanks
    8
    Thanked 0 Times in 0 Posts

    .htaccess mod_rewrite

    how i can remove the ".php" extension in url address bar using .htaccess but automatically??


    ex: when user type: www.mysite.com/forum.php
    and remove automatically the file extension to be: www.mysite.com/forum
    o the address url bar

    regards
    Last edited by urgido; 05-14-2008 at 11:54 AM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,851
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Code:
    RewriteEngine On
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php
    can serve www.mysite.com/forum.php for a request www.mysite.com/forum
    (You may need to change all links accordingly)
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Senior Coder nikos101's Avatar
    Join Date
    Dec 2006
    Location
    London
    Posts
    1,005
    Thanks
    58
    Thanked 10 Times in 10 Posts
    Is it just me or is the htaccess stuff confusing, especially when different hosts don't allow certain htaccess commands


  • #4
    New Coder
    Join Date
    May 2008
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I wonder.....

    My .htaccess is as follows;

    Options +FollowSymlinks
    RewriteEngine on
    RewriteRule ^(.*)\.htm $1.php [nc]
    RewriteRule ^(.*)\.html $1.php [nc]
    RewriteRule ^(.*)\.asp $1.php [nc]
    RewriteRule ^locate.php index.php?section=locate
    RewriteRule ^available.php index.php?section=available
    RewriteRule ^news.php index.php?section=news
    RewriteRule ^features.php index.php?section=features
    RewriteRule ^extras.php index.php?section=extras

    You can see what it's doing, but do I have create a new line for every 'section'? Or can it be done with a global wildcard?

  • #5
    New Coder
    Join Date
    May 2008
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Any help? PLEASE!!!!

  • #6
    New to the CF scene
    Join Date
    May 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what's ur original .hta

  • #7
    New Coder
    Join Date
    May 2008
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Options +FollowSymlinks
    RewriteEngine on
    RewriteRule ^(.*)\.htm $1.php [nc]
    RewriteRule ^(.*)\.html $1.php [nc]
    RewriteRule ^(.*)\.asp $1.php [nc]
    RewriteRule ^locate.php index.php?section=locate
    RewriteRule ^available.php index.php?section=available
    RewriteRule ^news.php index.php?section=news
    RewriteRule ^features.php index.php?section=features
    RewriteRule ^extras.php index.php?section=extras

  • #8
    New Coder
    Join Date
    May 2008
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    any ideas?

  • #9
    New Coder
    Join Date
    May 2008
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Still hoping that there is a way I can write a general rule.

    Anyone?

    Please!!!

    Thanks.

    David


  •  

    Posting Permissions

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