我真的不知道如何解釋這種情況,但我試了一下。所以,我有這個網址: HTTP://localhost/static/some_picture.png,我的文件夾是這個樣子:if/else和file_exists在htaccess中的功能mod_rewrite
- 靜/ X/picture.png
- 靜/ Y/logo.png
我想的是,如果用戶鍵入的URL中提到,他將看到「picture.png」什麼是在「靜/ X/picture.png」,但如果他的類型http://localhost/static/some_logo.png然後他會在「statics/y/logo.png」中看到「logo.png」。
我最後一次嘗試:
RewriteEngine On
RewriteCond statics/x/$1 -f
RewriteRule ^static/some_(.*)$ statics/x/$1 [L]
RewriteEngine On
RewriteCond statics/y/$1 -f
RewriteRule ^static/some_(.*)$ statics/y/$1 [L]
目前,我有這樣的.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule %{REQUEST_FILENAME} ^static/some_(.*)$
RewriteCond %{DOCUMENT_ROOT}/statics/x/%1 -f
RewriteRule ^static/some_(.*)$ statics/x/$1 [L]
RewriteEngine On
RewriteRule %{REQUEST_FILENAME} ^static/some_(.*)$
RewriteCond %{DOCUMENT_ROOT}/statics/y/%1 -f
RewriteRule ^static/some_(.*)$ statics/y/$1 [L]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
我看你是怎麼想的,我理解你的代碼,但不知何故,它只是不工作,我真的不知道爲什麼,我的整個代碼是這樣的:' RewriteEngine On RewriteCond%{REQUEST_URI} ^/static/some _(。*)$ RewriteCond%{DOCUMENT_ROOT}/statics/x /%1 - RewriteRule ^/statics/x /%1 [L] RewriteCond%{REQUEST_URI} ^/static/some _(。*)$ RewriteCond%{DOC UMENT_ROOT} /靜/ Y /%1 -f 重寫規則^ /靜/ Y /%1 [L] RewriteEngine敘述在 的RewriteCond%{REQUEST_FILENAME}!-f 重寫規則^(。*)$的index.php [QSA ,L] ' –