Cakephp controller not working in hosted server
up vote
-1
down vote
favorite
My cakephp project works perfectly on localhost, but doesn't work when I upload it to a hosted server.
This is the setup on my cPanel File Manager of hosted server:
/home/username/public_html/test
// webroot contents goes here
css/
img/
js/
index.php
/home/username/mycakeapp/
// necessary app directories go here
/config
/logs
/plugins
/src
/tmp
/vendor
I made sure to change WWW_ROOT in mycakeapp/config/paths.php on line 52:
define(‘WWW_ROOT’, ‘/home/username/public_html/test’ . DS);
I also changed index.php in public_html/test in the following 3 lines so that it correctly requires necessary files:
require '/home/username/mycakeapp/config/requirements.php';
require '/home/username/mycakeapp/vendor/autoload.php';
$server = new Server(new Application('/home/username/mycakeapp/config'));
After doing this, when i open the website.com/test, the site correctly opens the home.ctp file. However, upon going to other pages like website.com/test/users, it gives an error message like so:
The requested URL /test/users was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
My home.ctp file only has pure HTML code, so I guess it works fine. However, going to other sites which has CakePHP code, it doesn't seem to work at all. Plz help!
php cakephp cpanel cakephp-3.x
add a comment |
up vote
-1
down vote
favorite
My cakephp project works perfectly on localhost, but doesn't work when I upload it to a hosted server.
This is the setup on my cPanel File Manager of hosted server:
/home/username/public_html/test
// webroot contents goes here
css/
img/
js/
index.php
/home/username/mycakeapp/
// necessary app directories go here
/config
/logs
/plugins
/src
/tmp
/vendor
I made sure to change WWW_ROOT in mycakeapp/config/paths.php on line 52:
define(‘WWW_ROOT’, ‘/home/username/public_html/test’ . DS);
I also changed index.php in public_html/test in the following 3 lines so that it correctly requires necessary files:
require '/home/username/mycakeapp/config/requirements.php';
require '/home/username/mycakeapp/vendor/autoload.php';
$server = new Server(new Application('/home/username/mycakeapp/config'));
After doing this, when i open the website.com/test, the site correctly opens the home.ctp file. However, upon going to other pages like website.com/test/users, it gives an error message like so:
The requested URL /test/users was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
My home.ctp file only has pure HTML code, so I guess it works fine. However, going to other sites which has CakePHP code, it doesn't seem to work at all. Plz help!
php cakephp cpanel cakephp-3.x
Did you upload the .htaccess file that defines the necessary URL rewrite rules?
– Joni
Nov 22 at 2:44
@Joni no I wasn't aware that there is a .htaccess file. Is it necessary?
– JAVAnewbie
Nov 22 at 4:48
Has your autoload been updated for the host directory setup?
– Greg Schmidt
Nov 22 at 5:04
@Greg i didn't change anything from my autoload.php file.
– JAVAnewbie
Nov 22 at 5:07
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
My cakephp project works perfectly on localhost, but doesn't work when I upload it to a hosted server.
This is the setup on my cPanel File Manager of hosted server:
/home/username/public_html/test
// webroot contents goes here
css/
img/
js/
index.php
/home/username/mycakeapp/
// necessary app directories go here
/config
/logs
/plugins
/src
/tmp
/vendor
I made sure to change WWW_ROOT in mycakeapp/config/paths.php on line 52:
define(‘WWW_ROOT’, ‘/home/username/public_html/test’ . DS);
I also changed index.php in public_html/test in the following 3 lines so that it correctly requires necessary files:
require '/home/username/mycakeapp/config/requirements.php';
require '/home/username/mycakeapp/vendor/autoload.php';
$server = new Server(new Application('/home/username/mycakeapp/config'));
After doing this, when i open the website.com/test, the site correctly opens the home.ctp file. However, upon going to other pages like website.com/test/users, it gives an error message like so:
The requested URL /test/users was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
My home.ctp file only has pure HTML code, so I guess it works fine. However, going to other sites which has CakePHP code, it doesn't seem to work at all. Plz help!
php cakephp cpanel cakephp-3.x
My cakephp project works perfectly on localhost, but doesn't work when I upload it to a hosted server.
This is the setup on my cPanel File Manager of hosted server:
/home/username/public_html/test
// webroot contents goes here
css/
img/
js/
index.php
/home/username/mycakeapp/
// necessary app directories go here
/config
/logs
/plugins
/src
/tmp
/vendor
I made sure to change WWW_ROOT in mycakeapp/config/paths.php on line 52:
define(‘WWW_ROOT’, ‘/home/username/public_html/test’ . DS);
I also changed index.php in public_html/test in the following 3 lines so that it correctly requires necessary files:
require '/home/username/mycakeapp/config/requirements.php';
require '/home/username/mycakeapp/vendor/autoload.php';
$server = new Server(new Application('/home/username/mycakeapp/config'));
After doing this, when i open the website.com/test, the site correctly opens the home.ctp file. However, upon going to other pages like website.com/test/users, it gives an error message like so:
The requested URL /test/users was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
My home.ctp file only has pure HTML code, so I guess it works fine. However, going to other sites which has CakePHP code, it doesn't seem to work at all. Plz help!
php cakephp cpanel cakephp-3.x
php cakephp cpanel cakephp-3.x
asked Nov 22 at 2:10
JAVAnewbie
124
124
Did you upload the .htaccess file that defines the necessary URL rewrite rules?
– Joni
Nov 22 at 2:44
@Joni no I wasn't aware that there is a .htaccess file. Is it necessary?
– JAVAnewbie
Nov 22 at 4:48
Has your autoload been updated for the host directory setup?
– Greg Schmidt
Nov 22 at 5:04
@Greg i didn't change anything from my autoload.php file.
– JAVAnewbie
Nov 22 at 5:07
add a comment |
Did you upload the .htaccess file that defines the necessary URL rewrite rules?
– Joni
Nov 22 at 2:44
@Joni no I wasn't aware that there is a .htaccess file. Is it necessary?
– JAVAnewbie
Nov 22 at 4:48
Has your autoload been updated for the host directory setup?
– Greg Schmidt
Nov 22 at 5:04
@Greg i didn't change anything from my autoload.php file.
– JAVAnewbie
Nov 22 at 5:07
Did you upload the .htaccess file that defines the necessary URL rewrite rules?
– Joni
Nov 22 at 2:44
Did you upload the .htaccess file that defines the necessary URL rewrite rules?
– Joni
Nov 22 at 2:44
@Joni no I wasn't aware that there is a .htaccess file. Is it necessary?
– JAVAnewbie
Nov 22 at 4:48
@Joni no I wasn't aware that there is a .htaccess file. Is it necessary?
– JAVAnewbie
Nov 22 at 4:48
Has your autoload been updated for the host directory setup?
– Greg Schmidt
Nov 22 at 5:04
Has your autoload been updated for the host directory setup?
– Greg Schmidt
Nov 22 at 5:04
@Greg i didn't change anything from my autoload.php file.
– JAVAnewbie
Nov 22 at 5:07
@Greg i didn't change anything from my autoload.php file.
– JAVAnewbie
Nov 22 at 5:07
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
accepted
Upload your .htaccess file.
The part that's not working is the one that rewrites requests for "pretty" URLs like /users into requests for PHP scripts like /index.php?q=/users. The .htaccess file does that.
add a comment |
up vote
0
down vote
You should try changing App.base
parameter in ./config/app.php
like so:
'App' => [
// ...
'base' => '/test',
// ...
]
See the documentation here.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Upload your .htaccess file.
The part that's not working is the one that rewrites requests for "pretty" URLs like /users into requests for PHP scripts like /index.php?q=/users. The .htaccess file does that.
add a comment |
up vote
0
down vote
accepted
Upload your .htaccess file.
The part that's not working is the one that rewrites requests for "pretty" URLs like /users into requests for PHP scripts like /index.php?q=/users. The .htaccess file does that.
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Upload your .htaccess file.
The part that's not working is the one that rewrites requests for "pretty" URLs like /users into requests for PHP scripts like /index.php?q=/users. The .htaccess file does that.
Upload your .htaccess file.
The part that's not working is the one that rewrites requests for "pretty" URLs like /users into requests for PHP scripts like /index.php?q=/users. The .htaccess file does that.
answered Nov 22 at 13:28
Joni
75.5k996148
75.5k996148
add a comment |
add a comment |
up vote
0
down vote
You should try changing App.base
parameter in ./config/app.php
like so:
'App' => [
// ...
'base' => '/test',
// ...
]
See the documentation here.
add a comment |
up vote
0
down vote
You should try changing App.base
parameter in ./config/app.php
like so:
'App' => [
// ...
'base' => '/test',
// ...
]
See the documentation here.
add a comment |
up vote
0
down vote
up vote
0
down vote
You should try changing App.base
parameter in ./config/app.php
like so:
'App' => [
// ...
'base' => '/test',
// ...
]
See the documentation here.
You should try changing App.base
parameter in ./config/app.php
like so:
'App' => [
// ...
'base' => '/test',
// ...
]
See the documentation here.
answered Nov 22 at 10:57
Timur Asaliev
763
763
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53422964%2fcakephp-controller-not-working-in-hosted-server%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Did you upload the .htaccess file that defines the necessary URL rewrite rules?
– Joni
Nov 22 at 2:44
@Joni no I wasn't aware that there is a .htaccess file. Is it necessary?
– JAVAnewbie
Nov 22 at 4:48
Has your autoload been updated for the host directory setup?
– Greg Schmidt
Nov 22 at 5:04
@Greg i didn't change anything from my autoload.php file.
– JAVAnewbie
Nov 22 at 5:07