我的 .htaccess 文件应该是什么样子才能忽略 js 文件?

发布于 2024-11-10 17:12:10 字数 1703 浏览 0 评论 0原文

我不知道有什么有趣的事情,直到我尝试使用以下方法将 js 文件注入到视图中:

$this->headScript()->appendFile($this->baseUrl('/js/planilla.js'));
echo $this->headScript();

现在,我正在使用 Zend Framework,当我对 中的任何 css 文件执行相同的操作时,没有问题/public/css 文件夹,所以我真的不知道问题是什么。 js 文件夹和 js 文件确实存在,当我尝试通过浏览器访问它(http://domain.local/js/planilla.js)时,我收到以下错误消息:

异常信息:

消息:指定的控制器无效 (js) 堆栈跟踪:

0 /home/fiodorovich/library/ZendFramework/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))

1 /home/fiodorovich/library/ZendFramework/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()

2 /home/fiodorovich/library/ZendFramework/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()

3 /home/fiodorovich/public_html/gisele/public/index.php(26): Zend_Application->run()

4 {主要}

请求参数:

数组( '控制器' => 'js', '行动' => 'planilla.js', '模块' => '默认', )

现在我的 .htaccess 看起来像这样:

SetEnv APPLICATION_ENV development
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_URI} (^.*/gisele.local/.*)$  [NC]
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

任何帮助都将受到欢迎和重击,提前致谢...

编辑:虚拟主机文件

编辑2:我让这个东西工作了。

我必须将此行添加到 application.ini 文件才能使其正常工作:

resources.frontController.params.useDefaultControllerAlways = 1

I didn't know there was something funny with it until I tried to inject a js file into a view with this:

$this->headScript()->appendFile($this->baseUrl('/js/planilla.js'));
echo $this->headScript();

Now, I'm using the Zend Framework and there's no problem when I do the same thing with any css file within the /public/css folder so I really don't nknow what the problem might be. The js folder and js file DO EXIST, and when I try to just access it (http://domain.local/js/planilla.js) through the browser I get the following error message:

Exception information:

Message: Invalid controller specified (js)
Stack trace:

0 /home/fiodorovich/library/ZendFramework/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))

1 /home/fiodorovich/library/ZendFramework/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()

2 /home/fiodorovich/library/ZendFramework/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()

3 /home/fiodorovich/public_html/gisele/public/index.php(26): Zend_Application->run()

4 {main}

Request Parameters:

array (
'controller' => 'js',
'action' => 'planilla.js',
'module' => 'default',
)

Right now my .htaccess looks like this:

SetEnv APPLICATION_ENV development
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_URI} (^.*/gisele.local/.*)$  [NC]
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

Any help whatsoever will be welcomed and thud, thanks in advance...

EDIT: the vhost file

EDIT2: I got this thing to work.

I had to add this line to the application.ini file for it to work:

resources.frontController.params.useDefaultControllerAlways = 1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清浅ˋ旧时光 2024-11-17 17:12:10

这条线

RewriteCond %{REQUEST_URI} (^.*/gisele.local/.*)$  [NC]

看起来很可疑。尝试评论一下。
我的 .htaccess 文件如下所示。而且是绝对可行的。

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

RewriteRule ^(.*)$ index.php [NC,L,QSA]

The line

RewriteCond %{REQUEST_URI} (^.*/gisele.local/.*)$  [NC]

looks suspicious. Try to comment it.
My .htaccess file looks like this. And it is absolutably workable.

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

RewriteRule ^(.*)$ index.php [NC,L,QSA]
清引 2024-11-17 17:12:10

你的 .htaccess 没问题。尝试 http://domain.local/js/ 并检查您的文件是否仍然存在。

zend框架将你的js目录作为控制器,那么,你的公共目录中的“js”是作为css吗?你也可以尝试这个来确定。

RewriteRule ^js(.*)$ – [NC,L]

或者可能是您的环境设置。让我知道发生了什么。

Your .htaccess is fine. Try http://domain.local/js/ and check if your files are still there.

The zend framework is taking your js directory as a controller so, is "js" inside your public directory as css? you could also try this to make sure.

RewriteRule ^js(.*)$ – [NC,L]

or could be your enviroment settings. let me know what happens.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文