A
A
anti18692012-07-03 17:23:07
Apache HTTP Server
anti1869, 2012-07-03 17:23:07

Mod_rewrite not working for just one VirtualHost?

There are several absolutely identical virtual hosts. Here is their config of two of them:

<Directory "/home/user/">
    Options Indexes FollowSymLinks MultiViews Includes
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

<VirtualHost *:80>
  DocumentRoot /home/user/hostA/www
  CustomLog /home/user/hostA/logs/access.log combined
  ErrorLog /home/user/hostA/logs/error.log
    ScriptAlias /cgi-bin/ "/home/user/hostA/cgi-bin/"	
  ServerName www.hostA.ru
  ServerAlias hostA.ru	
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot /home/user/hostB/www
  CustomLog /home/user/hostB/logs/access.log combined
  ErrorLog /home/user/hostB/logs/error.log
    ScriptAlias /cgi-bin/ "/home/user/hostB/cgi-bin/"
  ServerName www.hostB.ru
  ServerAlias hostB.ru	
</VirtualHost>

In the web root of each host is .htaccess with the following content
RewriteEngine on
RewriteCond	%{REQUEST_FILENAME}	!-f
RewriteCond	%{REQUEST_FILENAME}	!-d
RewriteRule	^(.*)$	index.html [QSA,L]

So, the problem is that everything is fine on hostA. mod_rewrite works as it should, all requests are redirected to the root index.html
But on hostB it seems that mod_rewrite did not start at all. The symptoms are the same as if you make RewriteEngine off
. At the same time, .htaccess is processed, the rest of the directives work.
If you add a log:
RewriteLog /home/user/hostB/logs/rewrite.log
RewriteLogLevel 3

Nothing is written there
Which way to look? Thanks

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
anti1869, 2012-07-03
@anti1869

I decided as follows: I made a new DocumentRoot for HostB, began to copy files there from the old directory one by one. It turned out that for some unknown reason, the .xsl style file, which was hanging in the root of the site and was not even connected anywhere, leads to an error. Very strange. It's time to start the tambourine :)

A
Andrey Burov, 2012-07-03
@BuriK666

hmm, try swapping the descriptions of hostA and hostB.
in /home/user/hostB/ is there any .htaccess by any chance?

A
anti1869, 2012-07-03
@anti1869

no, there are no more .htaccess-s. Moreover, the problem started after the Apache upgrade. Before that everything worked. HostaB files were not touched.
Here mod_rewrite wrote the level 2 log:

127.0.0.1 - - [03/Jul/2012:18:30:13 +0400] [hostB.ru/sid#80bff70][rid#8245ac0/initial] (2) [perdir /home/user/hostB/www/] rewrite 'hostB/p/square.gif' -> 'index.html'
127.0.0.1 - - [03/Jul/2012:18:30:13 +0400] [hostB.ru/sid#80bff70][rid#8245ac0/initial] (2) [perdir /home/user/hostB/www/] strip document_root prefix: /home/user/hostB/www/index.html -> /index.html
127.0.0.1 - - [03/Jul/2012:18:30:13 +0400] [hostB.ru/sid#80bff70][rid#8245ac0/initial] (1) [perdir /home/user/hostB/www/] internal redirect with /index.html [INTERNAL REDIRECT]
127.0.0.1 - - [03/Jul/2012:18:30:13 +0400] [hostB.ru/sid#80bff70][rid#8256ac0/initial/redir#1] (1) [perdir /home/user/hostB/www/] pass through /home/user/hostB/www/index.html
127.0.0.1 - - [03/Jul/2012:18:30:13 +0400] [hostB.ru/sid#80bff70][rid#8258b08/subreq] (1) [perdir /home/user/hostB/www/] pass through /home/user/hostB/www/index.html

W
Webgr, 2014-05-06
@Webgr

The same problem arose. The difference between sites in domains, username, group and in the way of loading. I uploaded everything to the first site via ftp, to the second one via sftp. The rest is completely identical, the configs were created by the script, no differences at all.
Through sftp, the Russian file names were broken (a few pieces, not critical) and that's all I've noticed so far. Those. the file names were written incorrectly and mod-rewrite does not work, but this should not be related, I have no idea where to dig yet.
All similar actions were repeated many times under debian 6, no problems arose. This server is under debian 7.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question