Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-17-2011, 05:10 AM   PM User | #1
cancer10
Regular Coder

 
Join Date: Jun 2006
Location: India
Posts: 795
Thanks: 210
Thanked 2 Times in 2 Posts
cancer10 can only hope to improve
Question .htaccess : Hiding .php extensions in URL

Hi

I was wondering if there is anyway we can hide the .php extension in the URL using .htaccess?

For example

These URLs:
Code:
http://example.com/home.php
http://example.com/welcome/contact-us.php
http://example.com/home/support/email_us.php

Should look like
Code:
http://example.com/home
http://example.com/welcome/contact-us
http://example.com/home/support/email_us

Pls let me know if this is possible and how?


Many thanks
__________________
http://outlineme.com/cancer10
cancer10 is offline   Reply With Quote
Old 09-21-2011, 12:20 AM   PM User | #2
dhape
New Coder

 
Join Date: Aug 2011
Posts: 26
Thanks: 2
Thanked 1 Time in 1 Post
dhape is an unknown quantity at this point
Code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

With this rewrite, http://www.example.com/home.php is the same as http://www.example.com/home
__________________
“Computers are useless. They can only give you answers.”
(Pablo Picasso) Where To Find Coupons and Video Testimonials

Last edited by dhape; 09-21-2011 at 12:21 AM.. Reason: editing
dhape is offline   Reply With Quote
Users who have thanked dhape for this post:
cancer10 (09-21-2011)
Old 09-21-2011, 03:02 AM   PM User | #3
cancer10
Regular Coder

 
Join Date: Jun 2006
Location: India
Posts: 795
Thanks: 210
Thanked 2 Times in 2 Posts
cancer10 can only hope to improve
Thanks very much
__________________
http://outlineme.com/cancer10
cancer10 is offline   Reply With Quote
Old 09-23-2011, 01:08 AM   PM User | #4
Jinxy
New Coder

 
Join Date: Feb 2007
Posts: 86
Thanks: 0
Thanked 2 Times in 2 Posts
Jinxy has a little shameless behaviour in the past
This should do it for all extensions:

Code:
Options +MultiViews
Jinxy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:20 AM.


Advertisement
Log in to turn off these ads.