Forum Moderators: phranque

Message Too Old, No Replies

[.htacess] correct Rewrite rule syntax.

An easy clarification for a newbie

         

w9914420

2:01 pm on Mar 23, 2005 (gmt 0)

10+ Year Member



hi again

I am trying to create a rule in mod_rewrite that will look access the folder called "home" as its root folder the rule that I have written is as follows:

RewriteRule ^http://www.someone.com\$ /Home/ [R]

this does not work and causes my url not to function.

does anyone have any suggestions thanks.

regards.

sitz

4:24 pm on Mar 23, 2005 (gmt 0)

10+ Year Member



For basic RewriteRules, the syntax is:

RewriteRule $SOURCEPATH $DESTINATION $OPTIONAL_FLAGS

You've specified a full URL on the $SOURCEPATH side (you've also escaped the '$', so it's looking for a URL that it will never find. When a request for '/' comes in, mod_rewrite doesn't see:


http://www.example.com/

...it sees:

/

Thus, a rule closer to what you want would be:

RewriteRule ^/$ /Home/ [L,R]

Note that you only need the 'R' flag if you want to return a 302 redirect to the browser. You can leave off the 'R' and it will still work transparently to the browser. Note also that this rule is likely not *exactly* what you're looking for, but may get you onto the right track.

Have you Read The Fine Manual:
Apache 1.3: [httpd.apache.org ]
Apache 2.0: [httpd.apache.org ]

?

w9914420

6:54 pm on Mar 23, 2005 (gmt 0)

10+ Year Member



Thank you my friend,now it seems a lot clearly to me

regards

w9914420