ISAPI doesn't redirect

hi,

could someone please give me a hand and have a small look?
where am I wrong?

url:
http://mydomain.com/tool/apps/

ISAPI rewrtie rule:
RewriteRule ^/tool/apps(.*)$ /apps$1 [NC,L,R=301]

result:
http://mydomain.com/tool/apps/

expected result:
http://mydomain.com/apps/

Thanks a bulk

as can be viewed here:

Try removing the leading slash in front of /tools:


RewriteRule ^tool/apps(.*)$ /apps$1 [NC,L,R=301]

it helped in the sandbox, but not on the server itself.

what’s the difference between:

RewriteRule [1]/[/B]tool/apps(.)$ /apps$1 [NC,L,R=301]
RewriteRule [2]\/[/B]tool/apps(.
)$ /apps$1 [NC,L,R=301]
RewriteRule [3]tool[/B]/apps(.*)$ /apps$1 [NC,L,R=301]
?


  1. B ↩︎

  2. B ↩︎

  3. B ↩︎

On some servers you need the / , on others you don’t, depending on the version of ISAPI_Rewrite.
\/ is (normally, not sure about ISAPI_Rewrite) just another way to write / (where \ means: take the next character literally)

By the way, on some servers it takes a while before changes to that file take effect. You may want to contact your hoster.

10x.

huh? :slight_smile:

elad,

Apache 1.x required a leading / in the DocumentRoot’s .htaccess mod_rewrite directives; Apache 2.x KNOWS that the / is in the URL (not the URI) so it’s effectively prohibited. The result is:

# Apache 1.x
RewriteRule ^/{regex}$ {redirection} {optional flags}
# Apache 2.x
RewriteRule ^{regex}$ {redirection} {optional flags}
# Apache 1.x OR Apache 2.x
RewriteRule ^/?{regex}$ {redirection} {optional flags}

Making the leading / optional covers both cases.

As for \/, are you kidding? You do not escape the directory separator in regex or the redirection.

Regards,

DK

^ Same holds for ISAPI_Rewrite (IIS) :slight_smile: