如何解决静态内容的htaccess无法正常工作!
| 因此,我设置了以下几行,以将一些请求重定向到我的静态域:RewriteEngine On
RewriteBase /
RewriteRule ^img/(.*)$ http://static.mydomain.com/img/$1 [R=301]
RewriteRule ^css/(.*)$ http://static.mydomain.com/css/$1 [R=301]
RewriteRule ^js/(.*)$ http://static.mydomain.com/js/$1 [R=301,L]
但是由于某种原因,当我链接到一张图片时:
<img src=\"img/icons/hello.png\">
当静态服务器上确实存在它时,它会显示404(这实际上意味着它没有被重定向)。
我究竟做错了什么?我花了两个小时来尝试我所知道的一切,但没有找到解决方法。
提前非常感谢您。这是我完整的htaccess文件:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^img/(.*)$ http://static.mydomain.com/img/$1 [R=301]
RewriteRule ^css/(.*)$ http://static.mydomain.com/css/$1 [R=301]
RewriteRule ^js/(.*)$ http://static.mydomain.com/js/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
解决方法
调试重写的一种好方法是指定RewriteLog和RewriteLogLevel。您将日志级别设置为9,这记录了有关重写的很多事情。请记住在调试后禁用日志记录,因为这对于apache进程来说非常繁重。
RewriteLog文档
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。