Brian
Brian

Reputation: 1989

Help Needed With (I thought) Basic mod_rewrite Setup

I run my own server at home. I am attempting to do a mod_rewrite but I cannot seem to get it to work correctly.

Say my url is "http://www.site.com/". I have a user set up, whose public_html directory is serving pages; let's say that url is "http://www.site.com/~myUser/theDirectory/". What I am trying to do is set it so that when you type in "http://www.site.com/theDirectory/" it will actually serve the pages out of "http://www.site.com/~myUser/theDirectory/", but look like its coming from "http://www.site.com/theDirectory/". I edited my /etc/apche2/sites-enabled/default file and added these lines:

RewriteEngine On
RewriteRule ^theDirectory/$ /home/myUser/public_html/~myUser/theDirectory/

I also tried various versions of the rule:

RewriteRule ^/theDirectory/$ /home/myUser/public_html/theDirectory/
RewriteRule ^/var/www/html/theDirectory/$ /home/myUser/public_html/theDirectory/

I also made sure that the rewrite module was enabled. At first, I was getting this error:

[Fri Jun 17 18:11:35 2011] [error] [client xxx.xxx.xxx.xxx] File does not exist: /var/www/theDirectory

So I created that file, and now I am getting this error:

[Fri Jun 17 23:15:45 2011] [error] [client xxx.xxx.xxx.xxx] Directory index forbidden by Options directive: /var/www/theDirectory/

So, I'm not really sure where to go from here. Any and all advice will be appreciated. Thanks for taking the time to read.

Have a great day :-)

Upvotes: 0

Views: 111

Answers (1)

Francois Deschenes
Francois Deschenes

Reputation: 24969

Add the following to your virtual host configuration:

RewriteEngine on
RewriteRule ^/theDirectory(/.*)$ /home/myUser/public_html/theDirectory$1 [L]

Upvotes: 3

Related Questions