我正在申请。如果我的请求带有网址:http://localhost/invoice/public_html/index.php/string-inventory 一切正常。
如果我要求使用网址:http://localhost/invoice/public_html/index.php/string-inventory/new-record或http://localhost/invoice/public_html/index.php/string-inventory/
我的应用程序对.css或Js的服务器权限不正确。我解决了这种类型的问题,从index.php(没有css和js文件)到index.php /(有css和js文件),同时重定向到整个不同的页面。但这不是正确的方法。而且我为具有相同上下文的许多页面获取了.css和.js文件的404。
如果我发表评论
RewriteCond%{REQUEST_URI}!。 .css $ [NC] RewriteCond%{REQUEST_URI}!。 .js $ [NC]
然后是404,但文件未提供
我的.htaccess
Options +FollowSymLinks
RewriteEngine On
# Redirect requests to index.php
RewriteCond %{REQUEST_URI} !=/index.php
RewriteCond %{REQUEST_URI} !.*\.png$ [NC]
RewriteCond %{REQUEST_URI} !.*\.jpg$ [NC]
RewriteCond %{REQUEST_URI} !.*\.css$ [NC]
RewriteCond %{REQUEST_URI} !.*\.gif$ [NC]
RewriteCond %{REQUEST_URI} !.*\.js$ [NC]
#RewriteCond $1 !^(../src)
RewriteRule .* index.php?page=$1 [NC,L,QSA]
.css的预期网址应为 http://localhost/invoice/src/css/mystyles.css
在哪里 http://localhost/invoice/public_html/src/css/mystyles.css
但是如果控制器后没有任何动作,它将正常工作。而且我得到了预期的文件。同样适用于Js。
需要什么,问一下
答案 0 :(得分:0)
我无法查看您的文件结构,但您的/ invoice似乎是您的项目url,而public_html上的文件夹1实际上是您的公共根文件夹。
我建议您以public_html文件夹是实际的公用文件夹的方式来调整项目的apache设置(通常是/ etc / apache2 / sites-available)。这样可以解决上述问题。
.htaccess文件的另一个提示。您可以在重写之前检查是否所请求的url实际上不是现有文件(!-f)或目录(!-d),而不必在列表中定义所有可能的文件类型。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*)$ index.php?rt=$1 [NC,L,QSA] (or whatever rewrite you want to do)