Hide file extensions

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 22
Joined: 15 May 2014, 10:23

Hide file extensions

12 Dec 2014, 13:05

Hi

I read this page:
http://www.helicontech.com/isapi_rewrit ... amples.htm

in order to hide asp extensions of files. I need this file
http://www.mysite.com/file.asp
to be rewritten this way:
http://www.mysite.com/file/

but http://www.mysite.com/file.asp should remain accessible if someone calls this url

Which is the right way to do that?

Thanks

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: Hide file extensions

12 Dec 2014, 14:39

Hello,

it should be like this:

RewriteBase /
RewriteRule ^(.+)\.asp$ /$1/? [NC,R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1.asp [NC,L]

User avatar
Posts: 22
Joined: 15 May 2014, 10:23

Re: Hide file extensions

12 Dec 2014, 14:54

Thanks for your reply

It works but now it's not accessible with http://www.mysite.com/file.asp, but only with http://www.mysite.com/file/

Is it possible to have both?

thanks

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: Hide file extensions

12 Dec 2014, 15:01

"Is it possible to have both?"
- how do you see that?

You request:
- http://www.mysite.com/file.asp to be rewritten this way: http://www.mysite.com/file/
- but http://www.mysite.com/file.asp should remain accessible
Isn't it a little contradictory? Can't imagine how to have both. If you could clarify, I might help.

User avatar
Posts: 22
Joined: 15 May 2014, 10:23

Re: Hide file extensions

13 Dec 2014, 04:58

eheheheh you are right Anton, it can seems contradictory...
But now I have an environment where this is possible, and I have to replicate it the same way on another oone. I use the same .htaccess, but on the other one it doesn't work.

Maybe it's something IIS related and not isapi related

Thanks

User avatar
Posts: 1
Joined: 14 Dec 2014, 08:09

Re: Hide file extensions

14 Dec 2014, 08:12

Try:

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=permanent,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.asp -f
RewriteRule ^(.+)$ $1.asp [L,QSA]

User avatar
Posts: 22
Joined: 15 May 2014, 10:23

Re: Hide file extensions

15 Dec 2014, 05:39

no way...

It works with "/file.asp" but not with "file/"

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 12 guests