Forum Moderators: phranque
/
/languages/
/languages/en/
/languages/en/content/index.xml
/languages/en/content/news/index.xml
/languages/en/content/news/upload/index.xml
RewriteCond %{REQUEST_URI} !^/index.php [NC]
RewriteCond %{REQUEST_URI} !/robots.txt [NC]
RewriteCond %{REQUEST_URI} !/*.css [NC]
RewriteCond %{REQUEST_URI} !/*.dtd [NC]
RewriteRule (.*) /index.php
<Files "/languages/en/content/news/upload/*.*">
AuthType Basic
AuthName "upload files"
AuthUserFile /.htpasswd
require valid-user
</Files>
!/*.css negative matches example.com/.css
example.com/Xcss
example.com/9css
example.com/;css
example.com////.css
example.com////Xcss
example.com////9css
example.com////;css
example.com/////////.css
example.com/////////Xcss
example.com/////////9css
example.com/////////;css
example.com.css
example.comXcss
example.com9css
example.com;css !/*.dtd pattern. AuthName "12346"
AuthType Basic
AuthUserFile /vhost/vhost4/e/x/example.com/www/test/.htpasswd
AuthGroupFile /dev/null
require user abcdef
RewriteCond %{REQUEST_URI} !/*.css [NC]
RewriteCond %{REQUEST_URI} !/*.dtd [NC]
RewriteCond %{REQUEST_URI} !/*.js [NC]
RewriteCond %{REQUEST_URI} !/*.jpg [NC]
RewriteCond %{REQUEST_URI} !/*.gif [NC]
RewriteCond %{REQUEST_URI} !/*.png [NC]
RewriteCond %{REQUEST_URI} !/*.pdf [NC]
RewriteCond %{REQUEST_URI} !/favicon.ico [NC]
RewriteRule (.*) /index.php
<Files "/mnt/www/site/languages/en/content/news/upload/index.xml">
AuthType Basic
AuthName "upload"
AuthUserFile /mnt/www/site/.htpasswd
require valid-user
</Files>
<Files "/mnt/www/site/languages/en/content/news/upload/index.php">
AuthType Basic
AuthName "upload"
AuthUserFile /mnt/www/site/.htpasswd
require valid-user
</Files>
If that's true, then mod_rewrite works before mod_auth.
All the images and other files have rules, like:
RewriteCond %{REQUEST_URI} !/*.css [NC]
RewriteCond %{REQUEST_URI} !/*.dtd [NC]
RewriteCond %{REQUEST_URI} !/*.js [NC]
RewriteCond %{REQUEST_URI} !/*.jpg [NC]
RewriteCond %{REQUEST_URI} !/*.gif [NC]
RewriteCond %{REQUEST_URI} !/*.png [NC]
RewriteCond %{REQUEST_URI} !/*.pdf [NC]
RewriteCond %{REQUEST_URI} !/favicon.ico [NC]
RewriteRule (.*) /index.php
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/index.php [NC]
RewriteCond %{THE_REQUEST} !index\.php
RewriteRule (/|\.php)$ /index.php [L]
<Files "/mnt/www/site/languages/en/news/upload/*.*">
AuthType Basic
AuthName "subir archivos"
AuthUserFile /mnt/www/site/.htpasswd
require valid-user
</Files>
RewriteCond %{REQUEST_URI} !^/index.php [NC]
RewriteCond %{THE_REQUEST} !index\.php RewriteCond %{REQUEST_URI} !^/index.php [NC] because When I used only RewriteCond %{THE_REQUEST} !index\.php, I got errors. 127.0.0.1 - - [04/Mar/2013:09:45:52 +0800] "GET / HTTP/1.1" 500 346 [Mon Mar 04 09:45:52 2013] [error] [client 127.0.0.1] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace. I added again the RewriteCond %{REQUEST_URI} !^/index.php [NC] because When I used only RewriteCond %{THE_REQUEST} !index\.php, I got errors.
I thought that Files accepted only a real path
<Files "/mnt/www/site/languages/en/news/upload/*.*"> If I have the rewrite rules in the main .htaccess, with no <Files> section and the authentication lines in the internal .htaccess file, password is requested when accessing the file with the wrong url (http://example.com/languages/en/content/news/upload/).
... no password is requested when accessing the file with the right url (http://example.com/news/upload/)
I'm working on a personal site made in PHP where all the requests are redirected to /index.php and from there the whole system triggers what is needed, showing a page, validating user input, etc. That is working with no problems so far.
The content is made of .xml files but the url's are .php, so for instance when you request http://example.com/news/upload/index.php, the content you are actually getting is from /content/languages/en/news/upload/index.xml