Defining a document root in Apache2 / Cake PhP

I have a broken PHP Cake site that I did not write, but I was entrusted with a fix. I have a main controller, but no css / js / images, and when I click the link, I get 404 not found. I believe something is wrong with mod_rewrite or docroot configuration in apache.

While reading the Cake documentation, I came across this:

"application / Webroot In the production setup, this folder should serve as the document root for your application. The folders here also serve as places for CSS styles, images and JavaScript files.

In my / etc / apache 2 / sites-enabled / this-site, I see the following:

DocumentRoot /u02/data/docroots/this_site
    <Directory /u02/data/docroots/this_site>
            Options -Indexes
            AllowOverride none
            Order deny,allow
            Allow from all
    </Directory> 

So my question is: should the configuration block described above have: / u 02 / data / docroots / this_site / app / webroot as DocumentRoot and?

Elsewhere, can you think of fixing this problem?

+4
2

apache - .

docroot

:.../app/webroot DocumentRoot

, : .

css/js/images.

mod rewrite

:

DocumentRoot /u02/data/docroots/this_site/app/webroot
<Directory /u02/data/docroots/this_site/app/webroot>
        Options -Indexes
        AllowOverride none
        Order deny,allow
        Allow from all

        // added
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
</Directory> 

, .

, CakePHP, - , .

AllowOverride none

.htaccess apache. AllowOverride all , .htaccess, , .

+2

:

<VirtualHost *:80>
ServerAdmin xxxxxx@test.ro
ServerName test.ro
ServerAlias www.test.ro
DirectoryIndex index.php
DocumentRoot /u02/data/docroots/this_site
ErrorLog /u02/data/docroots/this_site/error.log
CustomLog /u02/data/docroots/this_site/access.log combined

<Directory "/u02/data/docroots/this_site">
Options -Indexes FollowSymLinks MultiViews
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>

</VirtualHost>

3 .htaccess:

/u02/data/docroots/this_site/app/webroot/.htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

/u02/data/docroots/this_site/app/.htaccess

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule    ^$    webroot/    [L]
RewriteRule    (.*) webroot/$1    [L]
</IfModule>

/u02/data/docroots/this_site/.htaccess

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>

Hope this helps;)

+1
source

Source: https://habr.com/ru/post/1527744/


All Articles