|
-
Aug 4th, 2004, 10:11 AM
#1
Thread Starter
Junior Member
mod_rewrite help - matching .php extension
Hi Guys,
I have the following in my .htaccess:
Code:
RewriteEngine on
RewriteRule ^/?$ template.php?section=home&page=home [L]
RewriteRule ^index.php?$ template.php?section=home&page=home [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ template.php?section=$1&page=$2 [L]
The first two RewriteRules work fine, but the last one... current will match something like ..com/section/page/ whereas I want it to match ..com/section/page.php
I've tried fiddling with it, but no luck. I'm very new to mod_rewrite.
Thanks, Phil
I am Remus, come from the dead
-
Aug 4th, 2004, 10:21 AM
#2
Thread Starter
Junior Member
UPDATE:
I got the mod-rewrite to work (sort of)
Code:
RewriteEngine on
RewriteRule ^/?$ template.php?section=home&page=home [L]
RewriteRule ^index.php?$ template.php?section=home&page=home [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/.php?$ template.php?section=$1&page=$2 [L]
Except it doesn't give me that page... i just gives back
Code:
<html><body></body></html>
Any ideas?
I am Remus, come from the dead
-
Aug 4th, 2004, 12:04 PM
#3
I'm new to this mod_rewrite thing, as cool as it is, but
Try echoing the value of $page from inside template.php, make sure that it's comming in right.
Secondly, I think that when it's encountering the / it is outside the parens, soooo.... maybe it should be:
RewriteRule ^([^/\.]+)/([^/\.]+.php)?$ template.php?section=$1&page=$2 [L]
But I'm not sure.
TG
-
Aug 5th, 2004, 03:43 AM
#4
Thread Starter
Junior Member
Almost... just needed to escape the '.' on the '.php' and it worked..
Code:
RewriteRule ^([^/\.]+)/([^/\.]+\.php)?$ template.php?section=$1&page=$2 [L]
Only thing is, $2 now includes the .php extension. I'll just have to snip it out with some PHP.
Thanks for your help
I am Remus, come from the dead
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|