You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Richard Riley <ri...@gmail.com> on 2010/09/25 07:23:53 UTC

[users@httpd] rewrite rules and allowoverride with mass vhost

Hi, Hopefully a simple Q as I am running around in circles a little bit.

I wish to use mass vhosts. I would like all sites to share a common
codebase/page repository - in this case "lib" which is a symbolic link
elsewhere. Each site has its own custom, db and images directories. I
can get these dirs onto the include path for php easily enough by
manipulating the path and using the HTTP_HOST value - so php include
access is not an issue.

What is causing me trouble however is getting "rewrite" to work in order
to point to the correct directories for http includes. e.g
url(images/pic.jpg). 

So I added the rewrite rules below but they are not triggering. As you
see I tried debugging but I am getting nothing into the log file.

,----
| LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
| LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
| LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
| LoadModule vhost_alias_module /usr/lib/apache2/modules/mod_vhost_alias.so
| 
| RewriteLog "/home/user/rewrite.log" 
| RewriteLogLevel 9
| 
| # get the server name from the Host: header
| UseCanonicalName Off
| 
| # include the server name in the filenames used to satisfy requests
| VirtualDocumentRoot /home/user/webs/%0/lib/
| 
| RewriteEngine On
| RewriteRule images /home/user/webs/%{HTTP_HOST}/images
| RewriteRule custom /home/user/webs/%{HTTP_HOST}/custom
| RewriteRule db     /home/user/webs/%{HTTP_HOST}/db
| 
| <Directory  />
| AllowOverride All
| </Directory>
`----

This is my first time trying to tinker with rewrite and its rather
daunting but I am pretty sure this is a simple oversight on my part ;)
Is it??

Any pointers/help much appreciated,

regards

r.




---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


[users@httpd] Re: rewrite rules and allowoverride with mass vhost

Posted by Richard Riley <ri...@gmail.com>.
Richard Riley <ri...@gmail.com> writes:

>
> So I added the rewrite rules below but they are not triggering. As you
> see I tried debugging but I am getting nothing into the log file.

This is now fixed. I had to create a .htaccess file and place rewrite
rules in there. I dont know why it didnt work from the httpd.conf config
but it works as a .htaccess.

Now the question is how to formulate the rewrite rules. Unfortunately
some sort of multiple call is done resulting in extended urls e.g

,----
| 127.0.0.1 - - [25/Sep/2010:11:43:17 +0200]
| [mysite.com/sid#b901b150][rid#b91f2a30/initial/redir#9] (3)
| [perdir /home/shamrock/webs/mysite.com/lib/] applying pattern
| '.*/images/(.+)$' to uri
| 'home/shamrock/webs/mysite.com/images/admin'
| 127.0.0.1 - - [25/Sep/2010:11:43:17 +0200]
| [mysite.com/sid#b901b150][rid#b91f2a30/initial/redir#9] (2)
| [perdir /home/shamrock/webs/mysite.com/lib/] rewrite
| 'home/shamrock/webs/mysite.com/images/admin' ->
| '/home/shamrock/webs/mysite.com/images/admin'
| 127.0.0.1 - - [25/Sep/2010:11:43:17 +0200]
| [mysite.com/sid#b901b150][rid#b91f2a30/initial/redir#9] (3)
| [perdir /home/shamrock/webs/mysite.com/lib/] add path info

******
| postfix: /home/shamrock/webs/mysite.com/images/admin ->
| /home/shamrock/webs/mysite.com/images/admin/shamrock/webs/mysite.com/images/admin
| 127.0.0.1 - - [25/Sep/2010:11:43:17 +0200]
******


| [mysite.com/sid#b901b150][rid#b91f2a30/initial/redir#9] (3)
| [perdir /home/shamrock/webs/mysite.com/lib/] applying pattern
| '^images/(.+)$' to uri
| '/home/shamrock/webs/mysite.com/images/admin/shamrock/webs/mysite.com/images/admin'
`----

My rewrite rules look like

,----
| RewriteEngine On
| RewriteRule  .*/images/(.+)$  /home/shamrock/webs/%{SERVER_NAME}/images/$1 
| RewriteRule  ^images/(.+)$  /home/shamrock/webs/%{SERVER_NAME}/images/$1
`----

I have tried digging around in the docs but havent really cottoned on to
how it all really works. It's a large subject for the new boy.

I just want a uri something like "images/d1/p1" to become
"/home/shamrock/webs/mysite.com/images/d1/p1"

How should I approach this?

regards

r.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org