Redirect requests only if the file is not found?

后端 未结 6 1403
借酒劲吻你
借酒劲吻你 2020-11-28 08:23

I\'m hoping there is a way to do this with mod_rewrite and Apache, but maybe there is another way to consider too.

On my site, I have directories set up for re-skinn

6条回答
  •  悲哀的现实
    2020-11-28 08:38

    # If requested resource exists as a file or directory, skip next two rules
    RewriteCond %{DOCUMENT_ROOT}/$1 -f [OR]
    RewriteCond %{DOCUMENT_ROOT}/$1 -d
    RewriteRule (.*) - [S=2]
    #
    # Requested resource does not exist, do rewrite if it exists in /archive
    RewriteCond %{DOCUMENT_ROOT}/archive/$1 -f [OR]
    RewriteCond %{DOCUMENT_ROOT}/archive/$1 -d
    RewriteRule (.*) /archive/$1 [L]
    #
    # Else rewrite requests for non-existent resources to /index.php
    RewriteRule (.*) /index.php?q=$1 [L] 
    

    From Rewrite if files do not exist

提交回复
热议问题