Hide file extension stops working

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 6
Joined: 30 Apr 2014, 22:43

Hide file extension stops working

20 Feb 2016, 20:02

Hi there,

I've been using the rewritter for many years. Recently I was attempting to update my rules to V.3 instead of using the v2 compatibility feature and for some reason the 'hide file extension' rule now stops working each night and returns 404 errors.

I've realised if i force quit the IIS Worker Process service it'll start working again.

I've tried looking at the error logs however not sure how to interpret them.

It is the only rule which is affected. I've since restored my rules to a v.2 backup and still the problem remains. I've run the latest updater as well.

The rule is exactly as per example website:

Code: Select all
#Redirect extension requests to avoid duplicate content
RewriteEngine On
RewriteRule ^((.*))\.asp$ $1 [NC,R=301,L]

#Internally add extensions to request
RewriteCond %{REQUEST_FILENAME}.asp -f
RewriteRule (.*) $1.asp%1


I'm unsure what I can do?

Thanks

User avatar
Posts: 402
Joined: 06 Mar 2012, 11:59

Re: Hide file extension stops working

21 Feb 2016, 12:21

Hello.

When ou say it is the only rule that is affected, I suppose there are others? Can I see your complete config, please?
There is no such thing in ISAPI_Rewrite that one rule stops working occasionally. This may be a file locking issue if this particular rule is located in a separate .htaccess file and something locks this file from reading when ISAPI_Rewrite tries to update its configuration.

User avatar
Posts: 6
Joined: 30 Apr 2014, 22:43

Re: Hide file extension stops working

21 Feb 2016, 18:27

Hi there

Thanks for the prompt reply.

This htaccess file has been working without problem for nearly 2 years. The problem only affects the hiding of the .asp files - all the other rules continue to work.

Thanks

Code: Select all
# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.104

RewriteEngine On

# www to non-www (NEW)
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^/(.*)$ https://%1/$1 [R=301,L]

# non-https to https
RewriteCond %{HTTP:Host} (.*)
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} (.*)
RewriteRule .? https://%1%2 [R=301,L]

#Redirect extension requests to avoid duplicate content
RewriteEngine On
RewriteRule ^((.*))\.asp$ $1 [NC,R=301,L]

#Internally add extensions to request
RewriteCond %{REQUEST_FILENAME}.asp -f
RewriteRule (.*) $1.asp%1

RewriteEngine On
RewriteCompatibility2 On
RepeatLimit 200
#RewriteBase

#  Defend your computer from some worm attacks
RewriteRule ^.*(?:global.asa|default\.ida|root\.exe|\.\.).*$ . [NC,F]

RewriteRule ^(.*/feeds/)(.*)news\.xml$ http://feeds.feedburner.com/gjsmachinery [R=301,L]
RewriteRule ^(.*/equipment/new/)(.*)p(\d+)/(.*)$ (/supplies/)product.asp\?p=$3 [NC,L,O]
RewriteRule ^(.*/equipment/new/)(.*)c(\d+)/(.*)\?(.*)$ (/supplies/)search.asp\?c=$3&$5 [NC,L]
RewriteRule ^(.*/equipment/new/)(.*)c(\d+)/(.*)$ (/supplies/)search.asp\?c=$3 [NC,L]
RewriteRule ^(.*/equipment/new/search.asp)(.*)$ (/supplies/)search.asp$2 [NC,L]
RewriteRule ^(.*/equipment/used/)(.*)c(\d+)/(.*)$ $1default.asp\?c=$3 [NC,L]
RewriteRule ^(.*/equipment/starter_kits/)(.*)p(\d+)/(.*)$ (/supplies/)product.asp\?p=$3 [NC,L,O]
RewriteRule ^(.*/equipment/methods/)(\w+)(.*)$ $1default.asp\?n=$2 [NC,L]
RewriteRule ^(.*/supplies/)(.*)c(\d+)/(.*)\?(.*)$ $1search.asp\?c=$3&$5 [NC,L]
RewriteRule ^(.*/supplies/)(.*)c(\d+)/(.*)$ (/supplies/)search.asp\?c=$3 [NC,L]
RewriteRule ^(.*/supplies/)(.*)s(\d+)/(.*)\?(.*)$ $1search.asp\?s=$3&$5 [NC,L]
RewriteRule ^(.*/supplies/)(.*)s(\d+)/(.*)$ (/supplies/)search.asp\?s=$3 [NC,L]
RewriteRule ^(.*/supplies/)(.*)p(\d+)/(.*)$ $1product.asp\?p=$3 [NC,L,O]
RewriteRule ^(.*/supplies/search)\?(.*)$ (/supplies/)search.asp\?$2 [NC,L]
RewriteRule ^(.*/supplies/newest)\?(.*)$ (/supplies/)search.asp\?srchNew=1&$2 [NC,L]
RewriteRule ^(.*/supplies/newest)(.*)$ (/supplies/)search.asp\?srchNew=1 [NC,L]
RewriteRule ^(.*/supplies/discounted)\?(.*)$ (/supplies/)search.asp\?srchDisc=1&$2 [NC,L]
RewriteRule ^(.*/supplies/discounted)(.*)$ (/supplies/)search.asp\?srchDisc=1 [NC,L]
RewriteRule ^(.*/supplies/featured)\?(.*)$ (/supplies/)search.asp\?srchFeat=1&$2 [NC,L]
RewriteRule ^(.*/supplies/featured)(.*)$ (/supplies/)search.asp\?srchFeat=1 [NC,L]
RewriteRule ^(.*/supplies/search.asp)(.*)$ (/supplies/)search.asp$2 [NC,L]
RewriteRule ^(.*/customerservice/news)\?(.*)$ (/customerservice/)news.asp\?$2 [NC,L]
RewriteRule ^(.*/customerservice/news/)(\d+)/(.*)$ (/customerservice/)news-article.asp\?n=$2 [NC,L]
RewriteRule ^(.*/customerservice/)(.*)n(\d+)/(.*)$ $1news-article.asp\?n=$3 [NC,L]
RewriteRule ^(.*/customerservice/case-studies/)d(\d+)/(.*)$ (/customerservice/case-studies/)article.asp\?d=$2 [NC,L]
RewriteRule ^(.*/support/)(.*)c(\d+)/(.*)$ $1search.asp\?c=$3 [NC,L]
RewriteRule ^(.*/customerservice/events/)(\d+)/(.*)$ (/customerservice/events/)details.asp\?idEvent=$2 [NC,L]

User avatar
Posts: 402
Joined: 06 Mar 2012, 11:59

Re: Hide file extension stops working

22 Feb 2016, 08:29

First, I see RewriteConpatibility2 directive is still there. This directive works for entire context, i.e. turns compatibility mode for entire .htaccess wherever it is written. Probably it is a good idea to remove it completely, however, I doubt it is somehow connected with your issue.
Next I see the rule you mentioned not working is using file check (-f), probably this is somehow connected with a malfunction. To correctly test for file existence ISAPI_Rewrite needs to have 'read' and 'list folder content' permissions on the location where the rule is applied. Could it be that something changes permissions on your system on a timely basis, something like Plesk panel? Also are you using Windows Authentication on this site, because I can imagine the issue is happening sometimes if the IIS process serving requests impersonates into a user that does not have required permissions.
Another option for you is to try Helicon Ape instead of ISAPI_Rewrite. Ape has same rewriting features and same syntax, plus it has much more modules and features inside, it is newer and uses completely different technology underneath. To try this option, you will need to uninstall ISAPI_Rewrite and install Ape as these two products may conflict. Also, all your rules should use ISAPI_Rewrite 3 syntax as Ape does not support RewriteCompatibility2 directive (and will ignore it). If Ape fixes your issue I will upgrade your license for free then.

User avatar
Posts: 6
Joined: 30 Apr 2014, 22:43

Re: Hide file extension stops working

23 Feb 2016, 03:40

Thank you for the suggestions.

I first tried removing the -f check and unfortunately any address using the default.asp or index.asp like https://website.com/ or https://website.com/folder/ prompted 404 errors.

I've restored all file permissions to ensure ISAPI_Rewrite has 'read' and 'list folder content'. Interestingly when I was upload a new website file yesterday, the FTP file upload failed and the rule stopped working. So may be what you are saying about a permission error.

I am not using Windows Authentication on the site.

I will see how the changes above go over night (as it seems to happen every single night) and if unsuccessful I will try Helicon Ape demo first.

Thank you again!

User avatar
Posts: 402
Joined: 06 Mar 2012, 11:59

Re: Hide file extension stops working

25 Feb 2016, 08:03

You cannot remove -f from your rule, it's logic is based on file check, it will only break the site.

Sometimes an antivirus software may block access to files causing the error. Please make sure you don't have any 'antiviruses' on your server.

User avatar
Posts: 6
Joined: 30 Apr 2014, 22:43

Re: Hide file extension stops working

25 Feb 2016, 20:28

Hi there,

It's been 48 hours since resetting the file permissions and the error has not occurred since!

Thanks so much for your help!

User avatar
Posts: 402
Joined: 06 Mar 2012, 11:59

Re: Hide file extension stops working

26 Feb 2016, 07:34

Glad to hear that!
You know where to find me if any issues then.

User avatar
Posts: 6
Joined: 30 Apr 2014, 22:43

Re: Hide file extension stops working

04 Mar 2016, 02:23

Hi there,

Unfortunately the problem has reoccurred all this week. I have no idea why it is so temperamental, there has been no modifications to the server during the last few weeks. Do you mind if I try Helicon Ape instead?

Thank you

User avatar
Posts: 402
Joined: 06 Mar 2012, 11:59

Re: Hide file extension stops working

04 Mar 2016, 09:51

This would be probably the best option. If the problem persists, you can increase logging level in Ape and check in logs for any suspicious messages at the time when configuration stop working. Please, don't forget to uninstall ISAPI_Rewrite, or at least remove it's ISAPI filter from the website you are configuring because Ape and ISAPI_Rewrite may conflict if installed simultaneously.

User avatar
Posts: 6
Joined: 30 Apr 2014, 22:43

Re: Hide file extension stops working

07 Apr 2016, 04:40

Hey there,

I tried uninstalling the re-writer and installing Ape and it discovered all my existing settings. However on any page load it tried to direct the page to be ..../default

so https://domain.co/page would redirect to https://domain.co/page/default

So I had to quickly uninstall it and revert back to the re-writer as it made the website unusable.

Thanks

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 20 guests