wilsonf1 Posted June 14, 2011 Share Posted June 14, 2011 I currently have a rewrite rule working perfectly fine for the following pages:directory/page1directory/page2directing to:directory/single-file.php?parameter=page1 directory/single-file.php?parameter=page2By doing this:RewriteRule ^directory/([^/\.]+)/?$ directory//single-file.php?parameter=$1 [L]But if I want the Urls to have .php on the end like this:directory/page1.phpdirectory/page2.phpHow do I edit this part of the rule?: ^directory/([^/\.]+)/?$thanks! Link to comment Share on other sites More sharing options...
wilsonf1 Posted June 14, 2011 Author Share Posted June 14, 2011 Arh, I have it working for .htm extensions, but it doesn't work for .php:RewriteRule ^directory/([^/\.]+).htm$ directory/single-file.php?single-file=$1 [L] Link to comment Share on other sites More sharing options...
MrFish Posted June 14, 2011 Share Posted June 14, 2011 Edit:After rereading your post I think I missunderstood. You are trying to parse .php into something. So this should work: RewriteRule ^directory/(.*)\.php directory/single-file.php?single-file=$1 Try this. I'm a bit new at it myself. I'm not sure if the backslash is necessary before .php. But I think it is before a '.' your are trying to include in the search.Original:You can use RewriteCond like an IF statement. For my site I don't want to apply the rule for any extensions so this is what I do- RewriteCond %{SCRIPT_FILENAME} !\.(gif|jpg|png|css|js|php|html|htm|zip)$ [NC]RewriteRule ^(.*)/(.*)$ index.php?page=$1&item=$2 [L]RewriteCond %{SCRIPT_FILENAME} !\.(gif|jpg|png|css|js|php|html|htm|zip)$ [NC]RewriteRule ^(.*)$ index.php?page=$1 [L] RewriteCond %{SCRIPT_FILENAME} !\.(gif|jpg|png|css|js|php|html|htm|zip)$ [NC] Using '!' says not. So if you don't find .gif or .jpg or .png (etc...) then do the rule below. Link to comment Share on other sites More sharing options...
Ingolme Posted June 14, 2011 Share Posted June 14, 2011 We usually just choose any locations that aren't files or directories: RewriteCond %{SCRIPT_FILENAME} !-fRewriteCond %{SCRIPT_FILENAME} !-dRewriteRule ^directory/(.*)$ directory/single-file.php?parameter=$1 [L] Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.