.htaccess 如果在定义的文件夹下找不到文件,如何重写

.htaccess 如果在定义的文件夹下找不到文件,如何重写,.htaccess,.htaccess,只有在给定文件夹下找不到文件时才需要重定向 我的代码是 <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^(theme|files|images|krishna)(.*)$ Swastik/public/$1$2 [L] RewriteRule ^(.*)$ Swastik/library/index.php [L] </IfModule> 重新启动发动机 重写规则^(主题|文件

只有在给定文件夹下找不到文件时才需要重定向

我的代码是

<IfModule mod_rewrite.c>
    RewriteEngine on

    RewriteRule ^(theme|files|images|krishna)(.*)$ Swastik/public/$1$2 [L]

    RewriteRule ^(.*)$ Swastik/library/index.php [L]

</IfModule>

重新启动发动机
重写规则^(主题|文件|图像|克里希纳)(.*)$Swastik/public/$1$2[L]
重写规则^(.*)$Swastik/library/index.php[L]
我必须将所有请求重写到Swastik/library/下,如果在Swastik/public中找不到文件,您可以使用:

RewriteCond %{DOCUMENT_ROOT}/Swastik/public%{REQUEST_URI} -f
RewriteRule (.*) Swastik/public/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* Swastik/library/index.php [L]

您是否测试了
重写cond^Swastik/public%{REQUEST_URI}-f
?是的,我尝试…:-)(顺便说一句,我从你身上学到了很多,阿努巴瓦,谢谢!)