mod_rewrite looking for the wrong file

Discuss practical ways rearrange URLs using mod_rewrite.

mod_rewrite looking for the wrong file

Postby mfhJoe » Wed Jun 18, 2008 8:43 am

Hi
This seems like a simple problem but the only bit of mod_rewrite I know I learned from here. I've got a slightly more complex problem now, I need to rewrite:
Code: Select all
http://domain.com/proj/app/file.php?profile=1
to
Code: Select all
http://domain.com/proj/app/file/profile/1/


I already have the code to rewrite file.php to file/ when there is no query string, but I'm struggling with the query string on the end. I'm using the following code:
Code: Select all
RewriteRule ^profile/([^/]+)/?$ file.php?profile=$1 [QSA,L]
But it gives this error in the Apache log:
Code: Select all
File does not exist: /Applications/MAMP/htdocs/proj/app/file
I understand why I'm getting the error (it should be /Applications/MAMP/htdocs/proj/app/file.php) but I don't know how I can code it to add .php to the end.

Sorry if this is a confusing description but this is hard to explain. I'd be happy to provide any further info about this if needed.

Cheers
Joe
mfhJoe
 
Posts: 5
Joined: Fri Jul 07, 2006 9:00 am

Postby richardk » Thu Jun 19, 2008 1:50 pm

What other rules do you have?

Try adding
Code: Select all
Options -MultiViews
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 115 guests

cron