Issue
When trying to access Javascript files from the webroot, I get the following error:
Missing Controller
Error:
JsController could not be found.
Error:
Create the class JsController below in file: app\Controller\JsController.php
<?php
class JsController extends AppController {
}
?>
I'm running without .htaccess files. Here is my configuration:
Listen 9090
<Directory "c:/wamp/apscmdb/">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride none
#
# Controls who can get stuff from this server.
#
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
<VirtualHost *:9090>
DocumentRoot "c:\wamp\apscmdb"
<Directory "c:/wamp/apscmdb/">
RewriteEngine On
RewriteBase /app/webroot
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</Directory>
</VirtualHost>
I'm trying the following code:
echo $this->Html->script('portal');
Which outputs:
<script type="text/javascript" src="/js/portal.js"></script>
I found this that sounds similar, but no solution has been provided: Error: JsController could not be found
Solution
Solution:
- Either use .htaccess files
- Or modify the HTML helper to output the appropriate URLs for webroot
Answered By - TechFanDan Answer Checked By - Katrina (WPSolving Volunteer)