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 10-04-2012, 11:01 PM   PM User | #1
arandomdan
New to the CF scene

 
Join Date: Oct 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
arandomdan is an unknown quantity at this point
Removing .php extension for first directory only

I have my .htaccess file set up to omit .php extensions from URLs. For instance:

mysite.com/page
mysite.com/item
mysite.com/about

Read from:

mysite.com/page.php
mysite.com/item.php
mysite.com/about.php

Which is great; however, I use the remaining part of the URL for parameters, which I want to be ignored. For instance, I want:

mysite.com/item/1234567890/a-product

To read from:

mysite.com/item.php

Rather than:

mysite.com/item/1234567890/a-product.php

Any idea how I can accomplish this in .htaccess? Here is my current .htaccess file:

Code:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
arandomdan is offline   Reply With Quote
Old 10-05-2012, 09:54 AM   PM User | #2
stevenmw
Regular Coder

 
stevenmw's Avatar
 
Join Date: Jun 2007
Location: OK
Posts: 446
Thanks: 26
Thanked 30 Times in 30 Posts
stevenmw is an unknown quantity at this point
If you can have a .htaccess in each directory then create a .htaccess for the directories you don't want to omit the .php and turn RewriteEngine off.

Code:
RewriteEngine Off
stevenmw is offline   Reply With Quote
Reply

Bookmarks

Tags
htaccess, html, php, web

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 06:34 AM.


Advertisement
Log in to turn off these ads.