Forum Moderators: phranque

Message Too Old, No Replies

.htaccess redirect issue

Intermitently working on a particular server

         

monkman

5:54 pm on Jan 11, 2010 (gmt 0)

10+ Year Member



Hello there, I have something of an issue with a redirect on one my servers. The code works fine on a few of my other servers, but on a particular server it only seems to want to work every now and again.

e.g.

user clicks on domainname.com redirects to domain.com/name, however, on this particular server when the domainname.com is clicked it'll redirect to domainname.com/homepage (i.e. domain.com) and every link clicked on from then on becomes domainname.com/name, domainname.com/about etc.

I've checked the .htaccess and the code is exactly the same on each server and other redirects doing similar things to different pages work every time, which is bizarre. Said code is:

RewriteCond %{HTTP:Host} ^(www\.domainname\.com)$
RewriteRule (.*) http\://www\.domain\.com/name\.html [L,I,R=301]

Anyone have any idea what this could be?

jdMorgan

10:50 pm on Jan 11, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you using Apache mod_rewrite ISAPI Rewrite, or some other "mod_rewrite-like" package?

Please be specific about what the expected/required behavior is, and what the unexpected/incorrect behavior is.

Jim

g1smd

2:59 am on Jan 12, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There looks to be several syntax errors in that code, not least HTTP:HOST and the unwanted escaping in the target URL.

However I'm not all that clear on what the actual question is, so please answer JDs questions in detail before we can proceed.

monkman

2:07 pm on Jan 13, 2010 (gmt 0)

10+ Year Member



Hi, sorry guys. This is ISAPI_Rewrite. And the problem is, on this particular server the redirects all don't seem to work.

The code below is the same on all servers, where the redirects DO work, which points to possible errors with the way the server (or indeed the ISAPI_Rewrite) has been set up. Any ideas on what this could be?

jdMorgan

5:41 pm on Jan 13, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you don't get a good answer here, I'd recommend asking over in the Microsoft IIS forum, where there's likley more expertise on ISAPI Rewrite syntax.

Be aware that --at least on Apache-- the hostname in the HTTP_HOST variable can contain an FQDN-format domain name (as in "example.com." with a period appended, or the hostname may have a port number appended, or it may have both, as in "example.com.:80".

Any of these permissible variations would cause your rule to fail (on Apache) because the pattern is end-anchored and makes no provision for them. Also on Apache, the parentheses around the hostname are not needed, since the contained subpattern is neither optional nor is it back-referenced. And the 'target' URL also does not needed escaping of colons, slashes, or periods (again, this may only apply to Apache mod_rewrite).

Jim