mod_rewrite if file exists

前端 未结 2 798
你的背包
你的背包 2020-12-19 14:42

I already have two rewrite rules that work correctly for now but some more code has to be added to work perfectly.

I have a website hosted at mydomain.com and all su

2条回答
  •  北海茫月
    2020-12-19 15:15

    The problem is that you need to provide the absolute file system path to get -f and -d working. If you’re in the document root, you can use this rule:

    RewriteCond $1 !^subs/
    RewriteCond %{DOCUMENT_ROOT}/subs/default/$1 -f [OR]
    RewriteCond %{DOCUMENT_ROOT}/subs/default/$1 -d
    RewriteRule ^(.*)$ subs/default/$1 [L]
    

    But if you’re somewhere else, it’s going to be hard to get the right path prefix.

提交回复
热议问题