Bug? or am I doing something wrong
3 posts
• Page 1 of 1
Bug? or am I doing something wrong
Hello,
I've got 2 servers, configured nearly identically except for the build of ISAPI_Rewrite3 installed.
Server1, which "works", has 3.1.0.60;
Server2, which "doesn't", has 3.1.0.62.
The differences are as follows. I am trying to do a rewrite rule, with somewhat different syntax from that in your examples, to change http://site.com to http://www.site.com.
On Server1, a rule such as this works:
RewriteCond %{HTTP:Host} ^site1\.com$
RewriteRule (.*) http\://www\.site1\.com$1 [NC,R=301]
This produces a result which I would expect:
$ wget site1.com/thiswill404 --spider
Spider mode enabled. Check if remote file exists.
--2012-08-01 17:21:29-- http://site1.com/thiswill404
Resolving site1.com... 1.2.3.4
Connecting to site1.com|1.2.3.4|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.site1.com/thiswill404 [following]
Spider mode enabled. Check if remote file exists.
--2012-08-01 17:21:29-- http://www.site1.com/thiswill404
Resolving http://www.site1.com... 1.2.3.4
Connecting to http://www.site1.com|1.2.3.4|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
On server2, site2.com does something very odd:
--2012-08-01 17:23:42-- http://site2.com/thiswill404
Resolving site2.com... 2.2.3.4
Connecting to site2.com|2.2.3.4|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.site2.comthiswill404 [following]
Spider mode enabled. Check if remote file exists.
--2012-08-01 17:23:42-- http://www.site2.comthiswill404/
Resolving http://www.site2.comthiswill404... failed: Name or service not known.
wget: unable to resolve host address `www.www.site2.comthiswill404'
For server2, the rewrite rule which works is as follows, after affixing a \/ to the .com.
RewriteCond %{HTTP:Host} ^site2\.com$
RewriteRule (.*) http\://www\.site2\.com\/$1 [NC,R=301]
Is this a known issue? I couldn't really tell if it was a bug, or fixed, while reading the changelog.
Will upgrading to the latest build fix this issue?
Thanks!
Mike
I've got 2 servers, configured nearly identically except for the build of ISAPI_Rewrite3 installed.
Server1, which "works", has 3.1.0.60;
Server2, which "doesn't", has 3.1.0.62.
The differences are as follows. I am trying to do a rewrite rule, with somewhat different syntax from that in your examples, to change http://site.com to http://www.site.com.
On Server1, a rule such as this works:
RewriteCond %{HTTP:Host} ^site1\.com$
RewriteRule (.*) http\://www\.site1\.com$1 [NC,R=301]
This produces a result which I would expect:
$ wget site1.com/thiswill404 --spider
Spider mode enabled. Check if remote file exists.
--2012-08-01 17:21:29-- http://site1.com/thiswill404
Resolving site1.com... 1.2.3.4
Connecting to site1.com|1.2.3.4|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.site1.com/thiswill404 [following]
Spider mode enabled. Check if remote file exists.
--2012-08-01 17:21:29-- http://www.site1.com/thiswill404
Resolving http://www.site1.com... 1.2.3.4
Connecting to http://www.site1.com|1.2.3.4|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
On server2, site2.com does something very odd:
--2012-08-01 17:23:42-- http://site2.com/thiswill404
Resolving site2.com... 2.2.3.4
Connecting to site2.com|2.2.3.4|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.site2.comthiswill404 [following]
Spider mode enabled. Check if remote file exists.
--2012-08-01 17:23:42-- http://www.site2.comthiswill404/
Resolving http://www.site2.comthiswill404... failed: Name or service not known.
wget: unable to resolve host address `www.www.site2.comthiswill404'
For server2, the rewrite rule which works is as follows, after affixing a \/ to the .com.
RewriteCond %{HTTP:Host} ^site2\.com$
RewriteRule (.*) http\://www\.site2\.com\/$1 [NC,R=301]
Is this a known issue? I couldn't really tell if it was a bug, or fixed, while reading the changelog.
Will upgrading to the latest build fix this issue?
Thanks!
Mike
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Bug? or am I doing something wrong
Hello Mike,
There's a directive called RewriteBase which "automatically strips the local directory prefix from the path and apply rules only to the remainder".
So in case you have "RewriteBase /" the rule should look like: RewriteRule ^folder/sub-folder$ ....
Your .htaccess file has this directive enabled automatically, while httpd.conf doesn't. This could be the source of your issue. So the value of (.*) in your case may vary depending on config files you use.
I'd also suggest using:
No '\' is needed.
Regards
Andrew
There's a directive called RewriteBase which "automatically strips the local directory prefix from the path and apply rules only to the remainder".
So in case you have "RewriteBase /" the rule should look like: RewriteRule ^folder/sub-folder$ ....
Your .htaccess file has this directive enabled automatically, while httpd.conf doesn't. This could be the source of your issue. So the value of (.*) in your case may vary depending on config files you use.
I'd also suggest using:
- Code: Select all
RewriteRule (.*) http://www\.site2\.com/$1 [NC,R=301]
No '\' is needed.
Regards
Andrew
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 0 guests