Forum Moderators: phranque

Message Too Old, No Replies

Problems to create RewriteRules within htaccess

I want to create foo.com/dir/subdir/ and foo.com/dir/

         

guarriman

9:46 pm on Aug 19, 2007 (gmt 0)

10+ Year Member



Hi.

With Apache 2, I'd like to insert a couple of RewriteRule lines within my '.htaccess' in order to create
[foo.com...] --> foo.com/script.php?dir=dir&subdir=subdir
[foo.com...] foo.com/script.php?dir=dir

I tried with:
RewriteRule ^(.*)/(.*)/ /script.php?dir=$1&subdir=$2
RewriteRule ^(.*)/ /script.php?dir=$1

but it works only with:
[foo.com...]

Any suggestion?

jdMorgan

11:41 pm on Aug 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd suggest using more-specific patterns and the [L] flag:

RewriteRule ^([^/]+)/([^/]+)/$ /script.php?dir=$1&subdir=$2 [L]
RewriteRule ^([^/]+)/$ /script.php?dir=$1 [L]

I assume you already have other working rules...

Jim

g1smd

12:17 am on Aug 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Just to be clear, the links present ON your pages do say this:

[foo.com...]

[foo.com...]

Those are the URLs that people see and then actually click on, yes?