Link to home
Start Free TrialLog in
Avatar of Julian Hansen
Julian HansenFlag for South Africa

asked on

.htaccess passing through non existent extension

I am having one of those developer moments where I am not seeing the obvious.

I have an .htaccess file that does two things

Either sends requests of the type

http://domain/service/blah/blah/blah => service.php?args=$1
Failing that everything is sent to index.php

All works - except for one small thing - the args passed to service .php starts with .php so using the above example service.php receives
.php/blah/blah/blah

Open in new window

Instead of
blah/blah/blah

Open in new window

The rewrite rule for service is as follows  
RewriteRule ^service(.*)$ service.php?args=$1 [L,NC,QSA]

Open in new window

What am I missing? Why the .php prefix?
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

I don't know but I see examples written these two ways.
RewriteRule ^service(.*)$ /service.php?args=$1 [L,NC,QSA]
RewriteRule ^service(.*)$ http://service.php?args=$1 [L,NC,QSA]

Open in new window

http://www.askapache.com/htaccess/htaccess.html#Htaccess_File_Syntax
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Julian Hansen

ASKER

Thanks Dave for the response.

The /service option won't work on my side - I am using a RewriteBase directive so all my rules are relative to that - but appreciate the feedback.
Glad you got it figured out anyway.
Found the solution on my own