【发布时间】:2014-06-28 02:36:29
【问题描述】:
<IfModule mod_rewrite.c>
# Enable rewrite engine
RewriteEngine On
#Removes access to the system folder by users.
RewriteCond %{REQUEST_URI} ^app.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
# Some extra conditions
# skip these paths for redirection
RewriteRule ^img/(.*) public/assets/img/$1 [L]
RewriteRule ^css/(.*) public/assets/css/$1 [L]
RewriteRule ^js/(.*) public/assets/js/$1 [L]
RewriteRule ^plugins/(.*) public/assets/plugins/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_URI} !^.*\.(jpg|css|js|gif|png)$ [NC]
RewriteRule ^(.*)$ public/index.php?url=/$1 [QSA,L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 /index.php
</IfModule>
除了当我加载像 localhost/login/(尾部斜杠)这样的 URL 时,它没有加载资源之外,这种重写是有效的。当我使用localhost/login 时,它会加载所有图像和 CSS 文件。有人可以帮我解决这个问题。
【问题讨论】:
-
这类问题可能更适合Pro Webmasters Stack Exchange 网站。
标签: php .htaccess resources rewriting