Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite issues.

         

Archigos

3:56 am on Feb 25, 2009 (gmt 0)

10+ Year Member



I hope jdMorgan is around as he seems like a great moderator and seems to be very helpful.

An example of the directory stucture I'm using is:
/root (has a copy of Joomla installed)
/root/.htaccess (with mod_rewrite for Joomla)
/root/college (folder linked to a virtual host college.***.net)
/root/college/user/ (for other students to host some of their work)

There is a .htaccess in the /root folder only and not the others. When you visit college.***.net the index.php runs fine, but if you attempt to go to college.***.net/user/ I get a Forbidden [403]. I need to figure out a way to allow directory listing for the /user/ folder.

Based on a few posts I've read on this forum, I've tried both of the following:
Adding to the root .htaccess rewriteCond %{REQUEST_URI}!^/(college)/ as the first or last condition for each RewriteRule.
Created a new .htaccess in both /college and /college/user that only contained RewriteEngine off and none of it seems to work.

Below is a copy of the contents of the original .htaccess in /root

Options +FollowSymLinks

RewriteEngine On

RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=¦\%3D) [OR]
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
RewriteCond %{QUERY_STRING} (\<¦%3C).*script.*(\>¦%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=¦\[¦\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=¦\[¦\%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ index.php [F,L]

# RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/¦\.php¦\.html¦\.htm¦\.feed¦\.pdf¦\.raw¦/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

RewriteCond %{HTTP_HOST} ^******.net [NC]
RewriteRule ^(.*)$ [******.net...] [L,R=301]

Any help would be greatly appreciated as the other students are starting to worry about their grades since the pages can't be viewed correctly. (For the time being the files stored in the /college/user/ folder should all be .html files and no php, etc. if that matters.)

jdMorgan

12:19 pm on Feb 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> I need to figure out a way to allow directory listing for the /user/ folder.

Are we to understand that /user/ *does not* have a physically-existing index-page file in it? ... That is, there is no physical file at /user/index.php (or .htm, or .html)?

If this is the case, then add a !^/user/$ exclusion to your second rule, and change your Options directive to

 Options +FollowSymLinks +Indexes 

You will also need to move your third rule ahead of the other two. As it stands now, a request for the non-www domain may 'expose' the internally-rewritten filepaths in the URL, and you won't be happy if search engines discover this. A good general rule is to always put your external your external redirects first, in order from most-specific pattern/conditions (fewest URLs affected) to least-specific (most URLs affected), followed by your internal rewrites, again in order from most- to least-specific. There are exceptions, but they are rare.

Jim

Archigos

6:49 pm on Feb 25, 2009 (gmt 0)

10+ Year Member



Thank Jim...
You were correct, there is no index file in the /user directory, I made the changes you mentioned and it all seems to be working fine now.