Apache 2.2 mod_rewrite adding strange post fix info

highlander

Verified User
Joined
May 20, 2013
Messages
16
Hi, I am using mod_rewrite. When I request www.mydomain.com all is well. When I request mydomain.com the URL changes to this:

http://www.mydomain.com/home/admin/domains/mydomain.com/public_html

which results in a 404.

I've looked at my rewrite log and it seems to be adding the path info "home/admin/domains/mydomain.com/public_html/" for some reason... see the postfix line below.

Requesting mydomain.com rewrite log start:
[19/Feb/2014:09:45:44 --0800] [www.mydomain.com/sid#9ffeb8][rid#d06080/initial] (3) [perdir /home/admin/domains/mydomain.com/public_html/] add path info postfix: /home/admin/domains/mydomain.com/public_html/home -> /home/admin/domains/mydomain.com/public_html/home/admin/domains/mydomain.com/public_html/
[19/Feb/2014:09:45:44 --0800] [www.mydomain.com/sid#9ffeb8][rid#d06080/initial] (3) [perdir /home/admin/domains/mydomain.com/public_html/] strip per-dir prefix: /home/admin/domains/mydomain.com/public_html/home/admin/domains/mydomain.com/public_html/ -> home/admin/domains/mydomain.com/public_html/

Requesting www.mydomain.com rewrite log start... good one with no path info added:
[19/Feb/2014:09:44:52 --0800] [www.mydomain.com/sid#1bd2eb8][rid#1ed90e0/initial] (3) [perdir /home/admin/domains/mydomain.com/public_html/] strip per-dir prefix: /home/admin/domains/mydomain.com/public_html/ ->

I can post my htaccess file too but for starters is this a common problem with an easy solution?

I just don't understand why the path info is added before any rules are processed.

Also, if I enter a junk url such as "mydomain.com/junk" I just get a regular 404 without the addition of "/home/admin/domains/mydomain.com/public_html/". So, the only error case seems to be with "mydomain.com". If I enter "mydomain.com/index.php" that works fine.

So, there is something special about "mydomain.com" only.

Thanks for your help!
 
Last edited:
No, DNS is not related here, it must be apache. What is there in your .htaccess file? And httpd.conf for the virtual host? Is that only virtual host affected? Or do you have the same issue with anothers?
 
Hi, I figured out that it was a problem with my htaccess and a rewrite command.

Here is the code that caused problem:
# add www to top level domain
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^images\. [NC]
RewriteCond %{HTTP_HOST} !^static\. [NC]
RewriteCond %{HTTP_HOST} ^([a-z.]+)$ [NC]
RewriteRule ^/?(.*)$ http://www.%1/$1 [R=302,L,NE]

For some reason when I visited mydomain.com (instead of www.mydomain.com) the $1 seemed to become home/admin/domains/mydomain.com/public_html (which is the document root).

I don't understand the problem but was able to put in this code instead:

RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
 
Back
Top