Cakephp controller not working in hosted server
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 |
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 '18 at 2:44
@Joni no I wasn't aware that there is a .htaccess file. Is it necessary?
– JAVAnewbie
Nov 22 '18 at 4:48
Has your autoload been updated for the host directory setup?
– Greg Schmidt
Nov 22 '18 at 5:04
@Greg i didn't change anything from my autoload.php file.
– JAVAnewbie
Nov 22 '18 at 5:07
add a comment |
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 '18 at 2:10
JAVAnewbieJAVAnewbie
124
124
Did you upload the .htaccess file that defines the necessary URL rewrite rules?
– Joni
Nov 22 '18 at 2:44
@Joni no I wasn't aware that there is a .htaccess file. Is it necessary?
– JAVAnewbie
Nov 22 '18 at 4:48
Has your autoload been updated for the host directory setup?
– Greg Schmidt
Nov 22 '18 at 5:04
@Greg i didn't change anything from my autoload.php file.
– JAVAnewbie
Nov 22 '18 at 5:07
add a comment |
Did you upload the .htaccess file that defines the necessary URL rewrite rules?
– Joni
Nov 22 '18 at 2:44
@Joni no I wasn't aware that there is a .htaccess file. Is it necessary?
– JAVAnewbie
Nov 22 '18 at 4:48
Has your autoload been updated for the host directory setup?
– Greg Schmidt
Nov 22 '18 at 5:04
@Greg i didn't change anything from my autoload.php file.
– JAVAnewbie
Nov 22 '18 at 5:07
Did you upload the .htaccess file that defines the necessary URL rewrite rules?
– Joni
Nov 22 '18 at 2:44
Did you upload the .htaccess file that defines the necessary URL rewrite rules?
– Joni
Nov 22 '18 at 2:44
@Joni no I wasn't aware that there is a .htaccess file. Is it necessary?
– JAVAnewbie
Nov 22 '18 at 4:48
@Joni no I wasn't aware that there is a .htaccess file. Is it necessary?
– JAVAnewbie
Nov 22 '18 at 4:48
Has your autoload been updated for the host directory setup?
– Greg Schmidt
Nov 22 '18 at 5:04
Has your autoload been updated for the host directory setup?
– Greg Schmidt
Nov 22 '18 at 5:04
@Greg i didn't change anything from my autoload.php file.
– JAVAnewbie
Nov 22 '18 at 5:07
@Greg i didn't change anything from my autoload.php file.
– JAVAnewbie
Nov 22 '18 at 5:07
add a comment |
2 Answers
2
active
oldest
votes
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 |
You should try changing App.base
parameter in ./config/app.php
like so:
'App' => [
// ...
'base' => '/test',
// ...
]
See the documentation here.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 |
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 |
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 '18 at 13:28
JoniJoni
76.3k997150
76.3k997150
add a comment |
add a comment |
You should try changing App.base
parameter in ./config/app.php
like so:
'App' => [
// ...
'base' => '/test',
// ...
]
See the documentation here.
add a comment |
You should try changing App.base
parameter in ./config/app.php
like so:
'App' => [
// ...
'base' => '/test',
// ...
]
See the documentation here.
add a comment |
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 '18 at 10:57
Timur AsalievTimur 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.
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 '18 at 2:44
@Joni no I wasn't aware that there is a .htaccess file. Is it necessary?
– JAVAnewbie
Nov 22 '18 at 4:48
Has your autoload been updated for the host directory setup?
– Greg Schmidt
Nov 22 '18 at 5:04
@Greg i didn't change anything from my autoload.php file.
– JAVAnewbie
Nov 22 '18 at 5:07