我试图设置z-push,它需要一个别名/Microsoft-Server-Activesync ,它指向VHost位置以外的另一个目录中的文件index.php 。 为了testing我在同一个path中设置一个文件,并创build了以下内容
Alias /info /var/www/z-push/info.php <Directory "/usr/share/z-push/"> Options -Indexes AllowOverride None Order allow,deny allow from all </Directory>
哪个不起作用,但是如果我改变这个别名
Alias /info.php /var/www/z-push/info.php
我可以通过url example.com/info.php访问它。 除了我需要能够有ActiveSync东西的工作example.com/info 。
我认为我可以用RewriteRule来解决这个问题,但我没有任何运气。
谢谢。
编辑:
这是我的虚拟主机configuration:
SetEnv RAILS_ENV production RewriteEngine On # Rewrite index to check for static RewriteRule ^/$ /index.html [QSA] # Rewrite to check for Rails cached page RewriteRule ^([^.]+)$ $1.html [QSA] DocumentRoot /var/www/redmine/public/ <Directory /var/www/redmine/public/> Options +FollowSymLinks +MultiViews AllowOverride all Order allow,deny Allow from all </Directory> Alias /Microsoft-Server-ActiveSync /var/www/z-push <Directory "/usr/share/z-push"> Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny Allow from all </Directory> php_flag magic_quotes_gpc off php_flag register_globals off php_flag magic_quotes_runtime off
我认为罪魁祸首就是你在configuration文件之上的这个rewrite规则:
RewriteRule ^([^.]+)$ $1.html [QSA]
启用此规则后,当您请求example.com/info时,会添加.html扩展名,您的请求将变为example.com/info.html 。
而且,当然,这样的文件不存在。 从我的日志中提取:
[error] [client xx.xx.xx.xx] File does not exist: /var/www/info.html
由于这个重写规则似乎是Rails所需要的,我不会build议你评论一下。
您可以修改此规则,添加重写条件,以便仅在请求的页面不是 /info :
RewriteCond %{REQUEST_URI} !^/info RewriteRule ^([^.]+)$ $1.html [QSA]