.htaccess !-f rule not working

前端 未结 4 1734
礼貌的吻别
礼貌的吻别 2020-12-29 10:24

I have been using simple mod_rewrite rules for my CMS for years and am now making a new version, I am seeing the rewriteCond not making sense- I have the standard \"if is no

相关标签:
4条回答
  • 2020-12-29 10:58

    Well, that should work.

    Try setting the following props in your .htaccess:

    RewriteLog /var/log/rewrite.log
    RewriteLogLevel 3
    

    To debug your requests. Remember to reset this value once you're done, otherwise you'll end up with a filled up harddrive.

    0 讨论(0)
  • 2020-12-29 11:04

    Perhaps using RewriteLog and RewriteLogLevel to debug what it's doing?

    (From http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html)

    0 讨论(0)
  • 2020-12-29 11:18

    The RewriteConditions only apply to the next rule. You want this:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]+)$ index.php?page=$1
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]+)/([^/]+)$ index.php?page=$1&var=$2
    
    0 讨论(0)
  • 2020-12-29 11:18

    If you are using Apache 2.2, then you MUST read this:

    http://amandine.aupetit.info/135/apache2-mod_rewrite/

    Spoiler: what you will need to write is actually:

    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-l           
    

    Merc.

    0 讨论(0)
提交回复
热议问题