Canonicalization Issue

ISAPI_Rewrite is a powerful URL manipulation engine based on regular expressions
User avatar
Posts: 5
Joined: 14 Jan 2013, 13:58

Canonicalization Issue

14 Jan 2013, 14:31

Hi Everyone,

I'm new on here and pretty new to ISAPI so any help is much appreciated.

I'm trying to improve the on-site seo of a wordpress site that runs on IIS (I know!). The structure of the site is a bit of a disaster and to make things more complicated the designer has set certain file permissions that I'm struggling to get my head around. I basically want to redirect the www. version to the non-www. version and also redirect all /index.php to the root.

Here's what I've got to so far:

#This was the existing .htaccess contents controlling folder restrictions
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

#And this is what I added to sort out the canonicalisation
RewriteEngine on

RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^www\.(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://%2%3 [R=301]

RewriteRule ^index\.php$ http://thetaxclinic.ie/ [NC,R=301,L]


It's working as I want it to on the home page but the redirects aren't having any affect on any of the site's inner pages. Can anyone shed some light on what I'm doing wrong?

Thanks in advance,

Sean.

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

Re: Canonicalization Issue

15 Jan 2013, 12:20

Hello, Sean

Can you give an example of the page where the redirect doesn't work as expected.

User avatar
Posts: 5
Joined: 14 Jan 2013, 13:58

Re: Canonicalization Issue

15 Jan 2013, 12:41

Hi Anton,

Thanks for your response.

As I've mentioned, the site is http://thetaxclinic.ie and the redirects are all working fine on the home page. i.e. It's redirecting to the preferred non-www version and both thetaxclinic.ie/index.php & thetaxclinic.ie/home are redirecting as I want them to but these redirects aren't having any affect on the inner pages.

e.g. http://thetaxclinic.ie/index.php/tax-refunds/

I've just noticed actually that if I enter the url http://WWW.thetaxclinic.ie/index.php/tax-refunds/ it redirects back to the non-www version

but if I enter

WWW.thetaxclinic.ie/tax-refunds/ it doesn't redirect to the non-www version.

The set up of the site is a bit of a disaster to be honest. Why anyone would load wordpress onto IIS is beyond me but here we are regardless.

Any help is much appreciated.

Cheers,
Sean

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

Re: Canonicalization Issue

17 Jan 2013, 06:06

Hello, Sean

It occurred to me that your problems might be because you might be using v3 syntax in ISAPI_Rewrite 2.
Do you really use v2? Please confirm.

User avatar
Posts: 5
Joined: 14 Jan 2013, 13:58

Re: Canonicalization Issue

17 Jan 2013, 07:16

I've just had a look and it seems you could be on to something, I've just done a bit of research and apparently the name server that the site is on has isapi v3 built in! I read somewhere previously that the host (Blacknight) used ISAPI_Rewrite 2 but this doesn't seem to be the case.

Is the syntax I'm using correct for version 2? I just need to get the corresponding version for V3?

Thanks again for your assistance.

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

Re: Canonicalization Issue

18 Jan 2013, 09:08

Hello, Sean

The syntax you currently have is for v3. I just noticed that you posted the question in v2 forum, so I was unsure.
Please enable logging in httpd.conf by putting

RewriteLogLevel 9
LogLevel debug

Then make the test request that doesn't work and provide rewrite.log and error.log records you get.

User avatar
Posts: 5
Joined: 14 Jan 2013, 13:58

Re: Canonicalization Issue

28 Jan 2013, 14:41

Sorry for the late response. I tried a few times and can't find the httpd.conf file anywhere in the root.

Should I just create one? If so where should it be placed?

Apologies for my obvious ignorance on the subject.

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

Re: Canonicalization Issue

29 Jan 2013, 07:14

Hello, Sean

httpd.conf file in located in ISAPI_Rewrite installation folder.
You should put the logging directives into it.

User avatar
Posts: 5
Joined: 14 Jan 2013, 13:58

Re: Canonicalization Issue

30 Jan 2013, 11:33

Anton thanks again for your patience and assistance. The client is on a shared hosting plan and I can't access the IIS Manager or the ISAPI_Rewrite installation folder.

Are there any other alternatives? If not, I'll not worry too much about it. I've got the brunt of it sorted out but it's just annoying more than anything.

Sorry to be a pest.

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

Re: Canonicalization Issue

31 Jan 2013, 11:14

Hello, Sean

Could you try to fix your last rule like this:

RewriteRule ^index\.php(.*)$ http://thetaxclinic.ie$1 [NC,R=301,L]

Ans see if the behavior will change or not.

Return to ISAPI_Rewrite 2.x

Who is online

Users browsing this forum: No registered users and 10 guests