Challenge with Virtual Directory

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 29
Joined: 17 Apr 2013, 18:55

Challenge with Virtual Directory

17 Apr 2013, 19:00

I was migrating some of my IIS Scripts and something got changed.

Basically I would like to have the following redirect to our home page:

http://www.avst.com/downloads/public/Servers/ -> http://www.avst.com
http://www.avst.com/downloads/public/ -> http://www.avst.com
http://www.avst.com/downloads/ -> http://www.avst.com


However, I still want to be able to still have access to the direct files, like:
http://www.avst.com/downloads/public/Servers/CX-E%20Server%20Family%20Datasheet.pdf


Obviously, something went missing with some of my migration.

Appreciate the assistance in advance.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Challenge with Virtual Directory

18 Apr 2013, 00:22

Hello,

Please, try using the following:

Code: Select all
RewriteEngine on
RewriteBase /

RewriteCond {HTTP:Host} ^www\.avst\.com$ [NC]
RewriteRule ^downloads/public/Servers/$ http://www.avst.com [NC,R=301,L]

RewriteCond {HTTP:Host} ^www\.avst\.com$ [NC]
RewriteRule ^downloads/public/$ http://www.avst.com [NC,R=301,L]

RewriteCond {HTTP:Host} ^www\.avst\.com$ [NC]
RewriteRule ^downloads/$ http://www.avst.com [NC,R=301,L]


OR

Code: Select all
RewriteEngine on
RewriteBase /

RewriteCond {HTTP:Host} ^www\.avst\.com$ [NC]
RewriteRule ^downloads/(public/)?(Servers/)?$ http://www.avst.com [NC,R=301,L]


Regards
Andrew

User avatar
Posts: 29
Joined: 17 Apr 2013, 18:55

Re: Challenge with Virtual Directory

18 Apr 2013, 17:28

Actually....no dice. In fact, I event tried throwing an "index.asp" in the directory and it did not work. To be clear, I have a number of folders in the "http://www.avst.com/downloads/" directory. I do not have a root "index.asp" file in the directory.

However, when I added even a simple script like, I could not get it to redirect. I would just show the page. Running IIS 6, so I am a little stumped on this one.

#D/ # Record ID 1449 / Error Date:
RewriteCond %{HTTP:Host} ^[^.]+\.avst\.com$
RewriteRule ^/downloads/index.asp$ http://www.avst.com [NC,L,R=301]


In summary, I could not get your script to run correctly, without seeing the "Directory Listing Denied" message. When I added the "index.asp", I just saw the contents of the index.asp file. I could not get it to redirect.

What am I missing?

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Challenge with Virtual Directory

18 Apr 2013, 17:53

The only way to find out is to enable logging and provide us with rewrite.log for a testing request.
Logging issues are described in FAQ - http://www.helicontech.com/forum/10648-FAQ.html

Regards
Andrew

User avatar
Posts: 29
Joined: 17 Apr 2013, 18:55

Re: Challenge with Virtual Directory

18 Apr 2013, 20:12

Not seeing anything noticeable.

[4/18/2013 15:55:43] Map file c:\program files\helicon\isapi_rewrite3\mapfile1_20081014.txt - Loaded successfully
[4/18/2013 15:55:43] Map file c:\program files\helicon\isapi_rewrite3\mapfile2_20081014.txt - Loaded successfully
[4/18/2013 15:55:43] Map file c:\program files\helicon\isapi_rewrite3\mapfileav1_040110.txt - Loaded successfully
[4/18/2013 15:55:43] Map file c:\program files\helicon\isapi_rewrite3\mapfileav2_040110.txt - Loaded successfully
[4/18/2013 15:55:43] Map file c:\program files\helicon\isapi_rewrite3\mapfileav1_040110.txt - Loaded successfully
[4/18/2013 15:55:43] Map file c:\program files\helicon\isapi_rewrite3\mapfileav2_040110.txt - Loaded successfully
[4/18/2013 15:55:43] d:\websites\www.avst.com\.htaccess - Loaded successfully
[4/18/2013 16:01:19] d:\websites\www.avst.com\.htaccess - Loaded successfully
[4/18/2013 16:01:23] Map file c:\program files\helicon\isapi_rewrite3\mapfile1_20081014.txt - Loaded successfully

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Challenge with Virtual Directory

18 Apr 2013, 20:16

This is because you're looking at error.log, not rewrite.log.

Regards
Andrew

User avatar
Posts: 29
Joined: 17 Apr 2013, 18:55

Re: Challenge with Virtual Directory

18 Apr 2013, 22:53

Doh. Sorry about that.

User avatar
Posts: 29
Joined: 17 Apr 2013, 18:55

Re: Challenge with Virtual Directory

19 Apr 2013, 13:36

Since I have 1000+ rules, I added the one to the top. Hopefully this helps.

209.60.96.158 209.60.96.158 Fri, 19-Apr-2013 09:34:35 GMT [www.avst.com/sid#1166977644][rid#33457672/initial] (2) init rewrite engine with requested uri /downloads/public/servers/
209.60.96.158 209.60.96.158 Fri, 19-Apr-2013 09:34:35 GMT [www.avst.com/sid#1166977644][rid#33457672/initial] (1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
209.60.96.158 209.60.96.158 Fri, 19-Apr-2013 09:34:35 GMT [www.avst.com/sid#1166977644][rid#33457672/initial] (1) Htaccess process request d:\websites\www.avst.com\.htaccess
209.60.96.158 209.60.96.158 Fri, 19-Apr-2013 09:34:35 GMT [www.avst.com/sid#1166977644][rid#33457672/initial] (3) applying pattern '^/httpd(?:\.ini|\.parse\.errors).*$' to uri '/downloads/public/servers/'
209.60.96.158 209.60.96.158 Fri, 19-Apr-2013 09:34:35 GMT [www.avst.com/sid#1166977644][rid#33457672/initial] (3) applying pattern '^.*\.isrwhlp$' to uri '/downloads/public/servers/'
209.60.96.158 209.60.96.158 Fri, 19-Apr-2013 09:34:35 GMT [www.avst.com/sid#1166977644][rid#33457672/initial] (3) applying pattern '^downloads/(public/)?(Servers/)?$' to uri '/downloads/public/servers/'
209.60.96.158 209.60.96.158 Fri, 19-Apr-2013 09:34:36 GMT [www.avst.com/sid#1166977644][rid#33452888/initial] (2) init rewrite engine with requested uri /favicon.ico
209.60.96.158 209.60.96.158 Fri, 19-Apr-2013 09:34:36 GMT [www.avst.com/sid#1166977644][rid#33452888/initial] (1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
209.60.96.158 209.60.96.158 Fri, 19-Apr-2013 09:34:36 GMT [www.avst.com/sid#1166977644][rid#33452888/initial] (1) Htaccess process request d:\websites\www.avst.com\.htaccess
209.60.96.158 209.60.96.158 Fri, 19-Apr-2013 09:34:36 GMT [www.avst.com/sid#1166977644][rid#33452888/initial] (3) applying pattern '^/httpd(?:\.ini|\.parse\.errors).*$' to uri '/favicon.ico'
209.60.96.158 209.60.96.158 Fri, 19-Apr-2013 09:34:36 GMT [www.avst.com/sid#1166977644][rid#33452888/initial] (3) applying pattern '^.*\.isrwhlp$' to uri '/favicon.ico'
209.60.96.158 209.60.96.158 Fri, 19-Apr-2013 09:34:36 GMT [www.avst.com/sid#1166977644][rid#33452888/initial] (3) applying pattern '^downloads/(public/)?(Servers/)?$' to uri '/favicon.ico'

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Challenge with Virtual Directory

19 Apr 2013, 19:22

This one is easy! ))

(3) applying pattern '^downloads/(public/)?(Servers/)?$' to uri '/downloads/public/servers/'


The problem here is in that small '/' in fron of the request. If you implemented "RewriteBase /" as suggested in the rules above, '/' would be stripped automatically and the pattern would be matched. So all you need to do is to use RewriteBase directive OR add '/' to the pattern.

Regards
Andrew

User avatar
Posts: 29
Joined: 17 Apr 2013, 18:55

Re: Challenge with Virtual Directory

20 Apr 2013, 10:50

Thanks. I should have caught that. Thanks for the assitance.

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 21 guests