在.htaccess中使用Rewrite而不是httpd.conf中的Alias

时间:2011-04-13 10:29:14

标签: .htaccess mod-rewrite alias firefox4

尝试在共享主机上设置我自己的Weave服务器,显然我无法修改httpd.conf文件,因此我尝试使用Rewrite模块和.htaccess找到解决方法。

根据此处的文档https://wiki.mozilla.org/Labs/Weave/Sync/1.1/Setuphttps://wiki.mozilla.org/Labs/Weave/User/1.0/Setup,我创建了 .htaccess

RewriteEngine on
RewriteRule ^1.1(.*) server-sync/1.1/index.php/$1 [L]
RewriteRule ^1.0(.*) server-sync/1.0/index.php/$1 [L]
RewriteRule ^user/1.0(.*) weaveserver-registration/1.0/index.php/$1 [L]
RewriteRule ^user/1(.*) weaveserver-registration/1.0/index.php/$1 [L]

而不是

Alias /1.0 <full path to weave directory>/server-sync/1.1/index.php
Alias /1.1 <full path to weave directory>/server-sync/1.1/index.php
Alias /user/1.0 <full path to weave directory>/weaveserver-registration/1.0/index.php
Alias /user/1 <full path to weave directory>/weaveserver-registration/1.0/index.php

但我无法让它奏效。当我在Firefox 4中将“ http://www.mydomain.com/dir/weave ”设置为同步URL时,我总是得到请输入有效的服务器URL

这些重写规则是否正确?如果是这样我可以解决weave-server配置设置:/ 托管脚本的目录结构:

/home/myname/www/dir/weave/.htaccess
/home/myname/www/dir/weave/server-sync > weave server scripts
/home/myname/www/dir/weave/weaveserver-registration > weave server user scripts

1 个答案:

答案 0 :(得分:0)

我不知道如何编织请求文件,但我认为你可以测试一下:

RewriteRule ^1.1(.*) dir/weave/server-sync/1.1/index.php$1 [L]
RewriteRule ^1.0(.*) dir/weaveserver-sync/1.0/index.php$1 [L]
RewriteRule ^user/1.0(.*) dir/weaveweaveserver-registration/1.0/index.php$1 [L]
RewriteRule ^user/1(.*) dir/weaveweaveserver-registration/1.0/index.php$1 [L]

您的基本目录为/ = /home/myname/www/,您的规则应该将请求重写为/1.0dir/weave/server-sync/1.0/index.php$1,其中$1/1.0请求之后的任何内容。 (注意删除的斜线!或者你可以用双斜杠结束)。