问题
Trying to setup up my own Weave server on shared host, obviously I cannot modify httpd.conf file so I try to find a work-around using Rewrite module and .htaccess.
Based on documentation here https://wiki.mozilla.org/Labs/Weave/Sync/1.1/Setup and https://wiki.mozilla.org/Labs/Weave/User/1.0/Setup I created .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]
instead of
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
but I could not get it worked. I always get Please enter a valid server URL when I setup "http://www.mydomain.com/dir/weave" as Sync URL in Firefox 4.
are these Rewrite rules correct? if so I can prob weave-server config settings :/ Directory structure of my hosted scripts:
/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:
I did not know how weave requests file, but I think you can test this:
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]
Your base directory being / = /home/myname/www/
your rules should rewrite request to /1.0
to dir/weave/server-sync/1.0/index.php$1
where $1
is anything that stands after /1.0
request. (Note the removed slash ! Or you may end with doubled slashes).
来源:https://stackoverflow.com/questions/5647697/using-rewrite-in-htaccess-instead-of-alias-in-httpd-conf