Trying friendly URLs only

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 10
Joined: 25 Mar 2012, 23:23

Trying friendly URLs only

25 Mar 2012, 23:39

Using .htaccess on Apache was a piece of cake or I was lucky but RewriteRule on IIS7 has me defeated.
I've been at this for days and days reading Helicon's examples and elsewhere.

I have a long list of unique friendly URLs. Here is an example in plain english:
ask for www.luresandtours.com/vandermeer
browser loads http://www.luresandtours.com/listings.a ... goryID=134

The hosting company put this HTTPD.INI in my root:
[ISAPI_Rewrite]

### subdomain redirect v2 ###
RewriteCond Host: (?:.+\.)?luresandtours\.com
RewriteCond URL ^/public/(.*)
RewriteCond METHOD GET
RewriteRule ^/public/(.*) /$1 [I,R]
RewriteCond Host: (?:.+\.)?luresandtours\.com
RewriteCond METHOD POST
RewriteRule ^/public/(.*) /$1 [I]
RewriteCond Host: (?:.+\.)?luresandtours\.com
RewriteRule (.*) /public/$1 [I,L]

My website "starts" in the folder /public, so that's where I put this attempt at .htaccess

RewriteEngine on
RewriteBase /

RewriteRule ^http://www.luresandtours.com/vandermeer$ http://www.luresandtours.com/listings.a ... goryID=134 [NC,R=301,L]

And I've tried ^/vandermeer and ^vandermeer

Here is the path listed when the 404 comes up:
Requested URL http://www.luresandtours.com:80/public/vandermeer/

Any help appreciated.

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

Re: Trying friendly URLs only

26 Mar 2012, 07:12

Hello,

Lets start with the basics:
- What version of ISAPI_Rewrite do you have installed?
The syntax you've provided fits ISAPI_Rewrite 3, but ISAPI_Rewrite 3 does not support httpd.ini. At the same time ISAPI_Rewrite 2 supports httpd.ini, but does not support the syntax provided.

Regards
Andrew

User avatar
Posts: 10
Joined: 25 Mar 2012, 23:23

Re: Trying friendly URLs only

26 Mar 2012, 13:09

It's ISAPI 3 on a IIS7 server. Hosted by easycgi.com. I don't have access to the IIS management settings FWIW.

User avatar
Posts: 10
Joined: 25 Mar 2012, 23:23

Re: Trying friendly URLs only

29 Mar 2012, 10:40

I renamed the file from httpd.ini to .htaccess and still getting a 404 error. It is in the /public folder where my index.html is.
The host - easycgi.com are the ones that told me to use an httpd.ini and also later said I've got ISAPI_Rewrite 3 on IIS7.
Here I am being told that is not the correct match.

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

Re: Trying friendly URLs only

30 Mar 2012, 06:10

Now, when it's ISAPI_Rewrite 3 and you have .htaccess, please, insert the following:

Code: Select all
RewriteEngine on
RewriteBase /

RewriteRule ^test$ - [F]


After you have this rule you must receive FORBIDDEN after requesting easycgi.com/test.
try it and if you get FORBIDDEN - ISAPI_Rewrite 3 works and we need to work on rules.

regards
Andrew

User avatar
Posts: 10
Joined: 25 Mar 2012, 23:23

Re: Trying friendly URLs only

31 Mar 2012, 10:37

Looks like a problem. I put the .htaccess in my /public folder where all my html pages are.

RewriteEngine on
RewriteBase /

RewriteRule ^test$ - [F]

returned a standard 404 error page. I tried www.easycgi.com/test and www.luresandtours.com/test

I have a custom error page online so I add one line to the top:

ErrorDocument 404 /error404.html

RewriteEngine on
RewriteBase /

RewriteRule ^test$ - [F]

and it still went to a generic 404 page.

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

Re: Trying friendly URLs only

02 Apr 2012, 06:08

Try to insert the following in your httpd.conf:

Code: Select all
#enabling rewrite.log
RewriteLogLevel 9
#enabling error.log
LogLevel debug


and provide us with the error.log and rewrite.log for the testing request.

Regards
Andrew

User avatar
Posts: 10
Joined: 25 Mar 2012, 23:23

Re: Trying friendly URLs only

03 Apr 2012, 16:46

I can't get to the httpd.conf file and I said you'd like to see a log. This is the response I got.

"We apologize for any inconvenience this may have caused you. Please note that ISAPI rewrite rule and friendly URL's are supported in our server. But, please make sure that the httpd.ini file should be existed at the root of your account and then only it works fine. However, if we do write basic ISAPI rewrite code in httpd.ini file and your domain is pointing to subfolder, then you should have to use default website URL of your account i.e. http://luresandtours.easycgi.com for the proper functionality of the rewrite rule. Or else you should have write your own custom ISAPI rewrite code in such a way that it should works fine even with the domain which is pointing to the subfolder. "

I barely understand what they are saying there and s.... this is what I found they put in my root as httpd.ini

[ISAPI_Rewrite]

### subdomain redirect v2 ###
RewriteCond Host: (?:.+\.)?luresandtours\.com
RewriteCond URL ^/public/(.*)
RewriteCond METHOD GET
RewriteRule ^/public/(.*) /$1 [I,R]
RewriteCond Host: (?:.+\.)?luresandtours\.com
RewriteCond METHOD POST
RewriteRule ^/public/(.*) /$1 [I]
RewriteCond Host: (?:.+\.)?luresandtours\.com
RewriteRule (.*) /public/$1 [I,L]

RewriteRule ^/public/testing.asp http://www.luresandtours.com/index.html [I,O,RP,L]

********
browsing www.luresandtours.com/testing.asp opens a page with "Hello Word", not my home page. Any idea what they are playing at?
Past this, they are not going to help with coding as this apparently shows the httpd.ini is working from the root. Up to me (HELP!) to figure out how to do the rewrites.
Can we at least say the ISAPI_REWRITE is functioning and reading a httpd.ini file now? I don't know enough to parse what all that code above the rewriterule is doing.
Thank you.

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

Re: Trying friendly URLs only

04 Apr 2012, 05:41

You have ISAPI_Rewrite 2 syntax here. It could be that they have version 2, not 3.
Version 2 doesn't have logs, has different syntax. So, please, clarify the version first.

Regards
Andrew

User avatar
Posts: 10
Joined: 25 Mar 2012, 23:23

Re: Trying friendly URLs only

04 Apr 2012, 22:37

They gave me the wrong information last month, saying it was version 3.
Today: The ISAPI_REWRITE version 2.12 is running on the IIS 7 server.

Hope this helps.

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

Re: Trying friendly URLs only

05 Apr 2012, 06:15

Hello,

I'm taking your issue from Andrew as v2 is my domain.
Let's try to start with the following rule in your site-root httpd.ini:

RewriteRule /public/vandermeer http\://www.luresandtours.com/listings.asp\?ItemID=310&CategoryID=134 [I,RP]

Please try it and report the results.

User avatar
Posts: 10
Joined: 25 Mar 2012, 23:23

Re: Trying friendly URLs only

05 Apr 2012, 16:19

Actually I don't see where there sample is working either. I browse www.luresandtours.com/testing.asp and I get the "Hello World" they put in the testing.asp page - ie. no redirect.
Tried a a few other paths in the browser too and none are picked up and redirected.

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

Re: Trying friendly URLs only

06 Apr 2012, 04:54

"I browse www.luresandtours.com/testing.asp and I get the "Hello World" they put in the testing.asp page - ie. no redirect."
- why should it redirect? Where's the rule for this URL?

Have you tried the rule I provided you:
RewriteRule /public/vandermeer http\://www.luresandtours.com/listings.asp\?ItemID=310&CategoryID=134 [I,RP]

Try requesting www.luresandtours.com/public/vandermeer with the above rule in place. And report the result.

User avatar
Posts: 10
Joined: 25 Mar 2012, 23:23

Re: Trying friendly URLs only

06 Apr 2012, 11:08

Hi. I wasn't ignoring your suggestion. We crossed message posts.
I put that in as the only rule - browsed to www.luresandtours.com/public/vandermeer (hit Enter) >>>> generic 404 error page
Same with www.luresandtours.com/vandermeer

Some 404 information: Requested URL http://www.luresandtours.com:80/public/vandermeer/
Physical Path \\boswinfs01\home\users\web\b897\ez.luresandtours\public\vandermeer
Charlie

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

Re: Trying friendly URLs only

09 Apr 2012, 10:11

Hello, Charlie

So, do you have any other rules working for you?

Please try to put the following rule just for testing:

RewriteRule .* $0 [F]

Then make any request to your site and report the result (the expected one is 403 Forbidden error page).

Also please make sure you don't have ISAPI_Rewrite filter registered twice - one server and site level (only server-wide registration is necessary).

User avatar
Posts: 10
Joined: 25 Mar 2012, 23:23

Re: Trying friendly URLs only

09 Apr 2012, 12:20

No effect. I can still browse every page of my site with no error page coming up.
The httpd.ini is in the site root, a level above /public where all my html's reside.
I can't speak to how many times the filter is registered. I don't have access to that.

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

Re: Trying friendly URLs only

10 Apr 2012, 07:52

Could you please give examples of the URLs you request to browse to the site pages (and which work fine).
Also please indicate what RewriteRule is supposed to handle these requests.
And show all the rules you have.

User avatar
Posts: 10
Joined: 25 Mar 2012, 23:23

Re: Trying friendly URLs only

10 Apr 2012, 10:42

I have no working Rewrite Rules. Since I got switched from Linux hosting and .htaccess to IIS none of my pages are available by friendly URLs. ie. clients advertising friendly URLs in their ads are not getting hits on our site since the beginning of the year.

This example worked in .htaccess on the previous hosting:
Redirect /suttonmotel http://www.luresandtours.com/listings.a ... goryID=106

The person browsing: www.luresandtours.com/suttonmotel
was sent to: http://www.luresandtours.com/listings.a ... goryID=106

When I discovered it wasn't working on the EasyCGI hosting, support dropped a httpd.ini in my root and told me to start from there on my own.
They are hosting my domain in a way that caused a lot of trouble with paths coded into applications I have running and this was their solution. ie. the httpd.ini is being read because I can't delete it or I lose my site.

[ISAPI_Rewrite]

### subdomain redirect v2 ###
RewriteCond Host: (?:.+\.)?luresandtours\.com
RewriteCond URL ^/public/(.*)
RewriteCond METHOD GET
RewriteRule ^/public/(.*) /$1 [I,R]
RewriteCond Host: (?:.+\.)?luresandtours\.com
RewriteCond METHOD POST
RewriteRule ^/public/(.*) /$1 [I]
RewriteCond Host: (?:.+\.)?luresandtours\.com
RewriteRule (.*) /public/$1 [I,L]

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

Re: Trying friendly URLs only

11 Apr 2012, 05:15

It seems that ISAPI_Rewrite is not working for your site at all...
Let's check it the following way:
- put the following line into your httpd.ini

RewriteRule .* $0 [F]

- make request to any page on your site with wFetch

- send me the result/response from wFetch to [email protected]

- also make the same request in the browser and specify what result/error you get (or consult IIS log to see the response code)

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 0 guests