mod_rewrite - 添加 REQUEST_FILENAME 变量的路径
这是我的代码:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond application/public/%{REQUEST_FILENAME} -f
RewriteRule (.*) application/public/$1 [L]
我想表达:
- 如果文件
{REQUEST_FILENAME}
不存在 AND if fileapplication/public/%{REQUEST_FILENAME} 存在进行重写
示例结果:
- /style.css = /application/public/style.css
- /gfx/logo.png = /application/public/gfx/logo.png
- /index.php = /index.php
- /Welcome = /index.php?input=Welcome (它正在工作)
这个表达式的正确代码是什么?我想我需要换行:
RewriteCond application/public/%{REQUEST_FILENAME} -f
但我不知道如何...
完整的 .htaccess 列表:
RewriteEngine on
RewriteRule style,(.+).css tmp/merged/css,$1 [L,QSA]
RewriteRule script,(.+).js tmp/merged/js,$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond application/public/%{REQUEST_FILENAME} -f
RewriteRule (.*) application/public/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php?input=$1 [L,QSA]
(对不起我的英语)
Here is my code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond application/public/%{REQUEST_FILENAME} -f
RewriteRule (.*) application/public/$1 [L]
I want to make expression:
- If file
{REQUEST_FILENAME}
doesn't exist AND if fileapplication/public/%{REQUEST_FILENAME}
exists do rewrite
Example results:
- /style.css = /application/public/style.css
- /gfx/logo.png = /application/public/gfx/logo.png
- /index.php = /index.php
- /Welcome = /index.php?input=Welcome (it's working)
What is proper code for this expression? I think i need to change line:
RewriteCond application/public/%{REQUEST_FILENAME} -f
But i have no bloody idea how...
Full .htaccess listing:
RewriteEngine on
RewriteRule style,(.+).css tmp/merged/css,$1 [L,QSA]
RewriteRule script,(.+).js tmp/merged/js,$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond application/public/%{REQUEST_FILENAME} -f
RewriteRule (.*) application/public/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php?input=$1 [L,QSA]
(sorry for my english)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了一个小解决方法,但这不是优雅的解决方案:(
i've found small workaround, but it's not elegant solution :(