简体   繁体   中英

Using Rewrite in .htaccess instead of Alias in httpd.conf

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

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM