I'm having problem with configuration of my .htaccess file. Application is written in AngularJs, while restApi application is written in Codeigniter and it's located in /server folder.
This is my folder structure
My api folder structure
This is my .htaccess file on which i'm working on
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
The problem is that when ever i try to access my api resource i'm keep getting 404 page, while this works perfectly on my debian nginx server, that's why i'm guessing that this is the problem in .htaccess file
http://myApp.com/server/api/products/latest/1
I hope you guys can help me. If you need any additional information's please let me know and i will provide. Thank you in advance.
Try in .htaccess
RewriteBase /server/
Also make sure that in config.php
$config['index_page'] = ' ';
Related
Working on a site with php 7.2, Symfony 4 and Sonata admin 3.
In dev, on my machine, everything works fine, the site itself, and the two admins (user and content).
I have put everything on the final server (unfortunately, file by file, no console with S4 ! so, no "composer:install"...).
Still on dev, the site works fine, all functionalities.
But when I try to use the admin page, I only get a non-formatted page. None of the assets (css and js) seems to work!
However the source code are identical, on localhost and the distant site...
Can anyone help me
Edit : I found where the issue comes from : it's linked to .htaccess.
The http address I use ends in /public/index.php. I use .htaccess to shorten it and when using the .htacces redirection I can't get the assets of the admin page, while it works fine without redirection.
Is there something I should change in my .htaccess code ?
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ public/index.php
</IfModule>
I am using cake php version 2.4. My project is running well in my local machine and it is a simple test project. I uploaded it in live. It does not work in live and even all css file are not loading. Should I change any server configuration?
You should check below situation in your Online Server :
DocumentRoot is properly set
Example : DocumentRoot /cake_install/app/webroot
.htaccess file is configured properly.
webroot Directory have the correct permissions
Check all other file/folder permissions
Ensure apache rewrite module is on
Note : rewrite module should be enabled from your online server for CakePHP URLs
I used the following code in .htaccess file where app folder is located:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Now it works for me.
I seriously can't understand what is going on here. I just uploaded my web app from localhost to new domain-name on Windows IIS Server. When I try to access the web app, CSS files and images are not loaded and I get the following error:
"CssController could not be found."
I don't understand why it is doing this.
Although I've written code like this in my default.ctp:
echo $this->html->css('generic');
CSS files are placed in:
app\webroot\css
I have searched on Google and have tried everything, I even uncommented the line:
Configure::write('App.baseUrl',env('SCRIPT_NAME')); in core.php
But I still cannot get this to work. Please help me to resolve this issue.
Double check that you have all the .htaccess files in place.
Also making sure /app/webroot/ has its .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
Your request is trying to get the css file from /css/ but i'm thinking you don't have the proper .htaccess files in place to route it to the webroot and not to a controller!
also check if mod_rewrite is enabled
Edit: and then I saw the IIS part, you need some IIS equivalent to mod_rewrite
In this article you find all the information required for successfully run CakePHP web applications under Microsoft IIS web server: http://bakery.cakephp.org/articles/filippo.toso/2008/01/29/cakephp-on-iis
Here is a related question about getting cake to work on IIS: CakePHP 2.2.2 not working on Windows IIS7
I have kind of an unique situation.
I have developed a cakephp app and need to deploy it to a shared server with content.
I know generally we are supposed to have static content in webroot, but am not allowed to do so, as this application needs to be removed later on.
its a shared hosting and i can't change DocumentRoot or any admin related settings. I can however add .htacces files.
I have my files in the following order:
/webapp
/app
/lib
...
/webroot
I guess you get the point.
I was planning to deploy the entire 'webapp' folder along with the static site and have the login link so the people can come to the site as http://mysite.com/webapp/users/login.
Unfortunately I do not know the correct way to do this. I hope to preserve the directory structure as-is so that someone coming after me can easily modify and delete it.
Any help is appreciated.
UPDATE:
I forgot to mention that locally i used to access the site by http://localhost/webapp, which was based of a DocumentRoot/VirtualHost setting. I might not be able to do that on prod, so how can I translate that using routes?
You need to update the .htaccess files to reference /webapp/app/webroot/ instead of /app/webroot/.
Although I’d be tempted to just install the CakePHP app in the root of your web server’s publicly-accessible directory, use CakePHP’s built-in PagesController to serve the static files, and just remove the controllers as and when you need to.
If you want to serve CakePHP from a subdirectory using Apache, you're looking for the RewriteBase directive. Add the directive to each of your three .htaccess files (in CakePHP root, in app, and in app/webroot). For example, the root one will end up looking like:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /webapp
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Now Cake will be happy being served in your webapp subdirectory.
i follow this steps to configure my site on the host and it is work on this link
http://alashera.3owl.com/
/// steps ///
first i move all folders from myprojectfolder to public_html
second i remove myprojectfolder
third i move webroot folder from app to public_html and change path from index.php
/// one problem ///
but something wrong need to correct..when i clicked at any link to
enter to any class into controller it give me this error
i guess this error because i remove projectfolder (tet) but not sure....
one example :
before uploaded my project ..i used this links to enter to this classes in localhost like this
http://localhost/tet/galleries/
http://localhost/tet/articles/
after uploaded project and removed (tet) folder i use this links ..
http://alashera.3owl.com/galleries
http://alashera.3owl.com/articles
so why server cant see controllers classes..thanks
Looks like mod_rewrite is NOT working in your server.
Check if http://alashera.3owl.com/index.php/galleries (& http://alashera.3owl.com/index.php/articles) works. If that works, then I would suggest you check the following.
Is mod_rewrite enabled on the server?
Have you uploaded the relevant .htaccess or added appropriate rewrite rules to your virtual host configuration?
Is execution of .htaccess permitted in your server?
thanks for every one help me the correct answer with full steps is
move app, cake, plugins, vendors folder into your hosting root folder. It is user root folder on your hosting
delete .htaccess and index.php on cakephp root folder
move /app/webroot/. to /public_html folder
delete empty /app/webroot folder
edit /public_html/index.php to point to the ‘cake’ and ‘app’ directories. For example my public_html path for my domain is /home/myhost/public_html, so i point
ROOT to look at /home/myhost
APP_DIR to look at /home/myhost/app
CAKE_CORE_INCLUDE_PATH to look at /home/myhost/cake
edit this line on /public_html/index.php with your appropriate path
<?php
if (!defined('ROOT')) {
define('ROOT', DS.'home'.DS.'myhost');
}
if (!defined('APP_DIR')) {
define('APP_DIR', 'app');
}
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
define('CAKE_CORE_INCLUDE_PATH', DS.'home'.DS.'myhost');
}
?>
7-
2. Alter 1 .htaccess file
For the fix to work, modify your app/webroot/ .htaccess file to read the following:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L]
</IfModule>
8- change the home page from config/route
9-put database information from config/database