Results 1 to 12 of 12
  1. #1
    Join Date
    Dec 2005
    Posts
    549

    How to exclude files from mod_rewrite?

    I wish to exclude robot.txt from mod_rewrite

  2. #2
    RewriteRule ^/robots\.txt$ - [L]
    Dyslexics Have More Fnu

  3. #3
    Join Date
    Dec 2005
    Posts
    549
    thanks!....

  4. #4
    If you want to exclude more files, directories or whatever, you can use:

    RewriteRule ^/(dir_name|file_name\.extension|and_so_on) - [L]
    (this is for use with httpd.conf)

    For htaccess, use:


    RewriteRule ^(dir_name|file_name\.extension|and_so_on) - [L]
    Dyslexics Have More Fnu

  5. #5
    Join Date
    Dec 2005
    Posts
    549
    Doesn't seem to work

    RewriteRule ^(mysqldumper|robots\.txt) - [L]

    when i go www.domain.com/mysqldumper, i still get redirected by mod_rewrite

  6. #6
    How many rewriterules do you have? This one should be the first if you want to exclude things from rewrite process.
    Dyslexics Have More Fnu

  7. #7
    Join Date
    Dec 2005
    Posts
    549
    Here is my .htaccess file. where should i put it?

    RewriteEngine On

    RewriteRule ^$ index.html [QSA]
    RewriteRule ^([^.]+)$ $1.html [QSA]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond $1 !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
    RewriteRule ^(mysqldumper|robots\.txt) - [L]

  8. #8
    RewriteEngine On
    RewriteBase /
    RewriteRule ^(mysqldumper|robots\.txt) - [L]
    RewriteRule ^$ index.html [QSA]
    RewriteRule ^([^.]+)$ $1.html [QSA]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond $1 !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
    Dyslexics Have More Fnu

  9. #9
    Join Date
    Dec 2005
    Posts
    549
    Doesn't work

    I tried to shorten it to:

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteRule ^(.*)$ index.php/$1 [L]

    when i go to www.domain.com/robots.txt, i still get redirected to index.php. Is there something wrong with my server?

  10. #10
    Join Date
    Dec 2005
    Posts
    549
    The only way i managed to make it work is by placing a .htaccess file in each dir that i want to exclude. But it doesn't work if i want to password protect it.

    Is there anyway to turn off rewrite and enable password protection for a dir?

    I place this .htaccess file in the dir in question

    "
    RewriteEngine Off
    AuthType Basic
    AuthName "Restricted Area"
    AuthUserFile "/home/grabmail/.htpasswds/mysqldumper/passwd"
    require valid-user
    "

    Doesn't work. I still get redirected by mod_rewrite.

  11. #11
    Join Date
    Feb 2003
    Location
    L.A. C.A.
    Posts
    335
    Try this grabmail, it should work.

    Code:
    RewriteEngine On
    RewriteRule ^(index\.php|images|robots\.txt) - [L]
    RewriteCond %{REQUEST_FILENAME} !-f [OR]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)?$ index.php?page=$1 [QSA,L]
    Cleaned it up a little bit, so when a user requests /file.ext it will load /index.php?page=file.ext.

    Hope this works for you. Good luck.

  12. #12
    I have the same problem, but none of the above solutions is working.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •