httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From solprovi...@apache.org
Subject Re: [users@httpd] Very Puzzling Question About mod_rewrite
Date Fri, 02 Nov 2007 19:04:24 GMT
On 11/1/07, Jon Forrest <jlforrest@berkeley.edu> wrote:
> (This is on Solaris 10-x86 with Apache 2.2.4)
> When I give the URL
> 1)  http://www-demo.cchem.berkeley.edu/username/public_html
>
> everything works fine. However, for historical reasons,
> I can't require that people give the "/public_html" at
> the end of the URL. In other words, I want users to
> be able to enter
> 2) http://www-demo.cchem.berkeley.edu/username/
>
> to see the same results as produced by URL #1 .
> So, I decided to try mod_rewrite. I use the following
> in the proper VirtualHost section of my httpd.conf file:
>
> RewriteEngine on
> RewriteRule  ^(.+)$  $1/public_html/      [L]
>
> This doesn't work. The client sees a "403 Forbidden" message.
> The apache log says:
> "Directory index forbidden by Options directive:
> /users/chemweb/apache2/http-cchem/htdocs/username/public_html/"
>
> I don't understand why I'm getting this message when
> URL #1 above works.
>
> The rewrite log shows the following (I added the #numbers):
>
> #1 (2) init rewrite engine with requested uri /username/
> #2 (3) applying pattern '^(.+)$' to uri '/username/'
> #3 (2) rewrite '/username/' -> '/username//public_html/'
> #4 (2) local path result: /username//public_html/
> #5 (2) prefixed with document_root to
> /users/chemweb/apache2/http-cchem/htdocs/username/public_html/
> #6 (1) go-ahead with
> /users/chemweb/apache2/http-cchem/htdocs/username/public_html/ [OK]
> #7 (2) init rewrite engine with requested uri /username/index.html
> #8 (3) applying pattern '^(.+)$' to uri '/username/index.html'
> #9 (2) rewrite '/username/index.html' -> '/username/index.html/public_html/'
> #10 (2) local path result: /username/index.html/public_html/
> #11 (2) prefixed with document_root to
> /users/chemweb/apache2/http-cchem/htdocs/username/index.html/public_html/
> #12 (1) go-ahead with
> /users/chemweb/apache2/http-cchem/htdocs/username/index.html/public_html/
> [OK]
>
> Line #6 above looks correct to me so I don't understand why mod_rewrite
> tried the other possibilities.
>
> I'm guessing all these problem have something to do with directory
> protection but if this is true then I don't understand why URL #1
> works.
>
> Any ideas?
>
> Cordially,
> Jon Forrest

Try some basic settings before mod_rewrite.
- DirectoryIndex sets the file that Apache will serve if a directory
is requested.
- UserDir is the name of the directory appended onto a user's home
directory if a ~user request is received.
   UserDir public_html
   DirectoryIndex index.html
   http://www-demo.cchem.berkeley.edu/~username
will serve:
   /home/username/public_html/index.html

If you do not want the tilde (~) in the URLs, use mod_rewrite to add it.
   RewriteEngine On
   RewriteRule ^/(.*)$ /~$1 [P]

If you want to continue with the ideas in the long thread, think about
why httpd is attempting to find username directories under
/users/chemweb/apache2/htdocs/cchem.  Is that what you want?

solprovider

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


Mime
View raw message