Rewrite rule for URLs ending in dots

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 3
Joined: 16 Jul 2012, 08:58

Rewrite rule for URLs ending in dots

16 Jul 2012, 09:06

Hi,

We have a really old website with dead linkthroughs coming from other websites. The links are dead because the coders for these external websites are somewhat retarded. Anyway, how do I redirect a request for:

http://www.mydomain.com/dead_link...

to http://www.mydomain.com/the-actual-url/

I've tried RewriteRule ^dead_link(.+)$ http://www.mydomain.com/the-actual-url/ [NC,R=301,L] but it didn't work.

Cheers!

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

Re: Rewrite rule for URLs ending in dots

16 Jul 2012, 10:10

Hello,

The dots are supposed to be escaped, although your rule also could be applied.
The reason it didn't work can be figured out from logs. Simply enable logs as described in FAQ and provide us with the log for the testing request.

Regards
Andrew

User avatar
Posts: 3
Joined: 16 Jul 2012, 08:58

Re: Rewrite rule for URLs ending in dots

16 Jul 2012, 10:38

Thanks Andrew,

There is nothing in the logs about this redirect (log level is set to 9). The error I'm getting is:

Code: Select all
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.
Requested URL: /dead_link...


We are on a Windows Server 2008 R2 machine running IIS 7.5.

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

Re: Rewrite rule for URLs ending in dots

16 Jul 2012, 10:43

It's states in FAQ that ISAPI_Rewrite has its own logs in Helicon installation folder, called rewrite.log and error.log.

Regards
Andrew

User avatar
Posts: 3
Joined: 16 Jul 2012, 08:58

Re: Rewrite rule for URLs ending in dots

16 Jul 2012, 10:58

Logging is enabled and set to level 9 and has been working fine for months.

However, this particular error (redirecting a ... URL) will not be found in the Isapi Rewrite logs because the request is handled and processed by IIS and is not even passed to Isapi Rewrite. Since posting here I've found out that IIS does not like unconventional file extensions and maps and will by default handle these with its own 404 application error page. The way around this is to add the following line to the web.config file:

Code: Select all
<system.web>
    <httpRuntime relaxedUrlToFileSystemMapping="true" />
</system.web>


After that, the rewrite rule works fine! Cheers...

Code: Select all
RewriteRule ^dead_link(.+)$ http://www.mydomain.com/the-actual-url/ [NC,R=301,L]

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 19 guests