.htaccess for cakephp

后端 未结 5 2118
时光取名叫无心
时光取名叫无心 2020-11-28 04:52

I\'m trying to get a CakePHP application to work. For this, I\'ve set up a brand new Debian installation, updated the configuration and put everything in /var/www, which has

相关标签:
5条回答
  • 2020-11-28 05:25

    If allowed by your provider you may put all in the httpd.conf file as follow

    <Directory /var/www>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      allow from all
      <IfModule mod_rewrite.c>
          RewriteEngine on
          RewriteRule    ^$    webroot/    [L]
          RewriteRule    (.*) webroot/$1    [L]
      </IfModule>
    </Directory>
    

    And so on for others directories...

    0 讨论(0)
  • 2020-11-28 05:34

    Removing .htaccess from main file may solve this problem. It worked for me(need not remove from webroot)

    0 讨论(0)
  • 2020-11-28 05:39

    CakePHP has only one .htaccess file inside webroot directory. No need more .htaccess files. You must set app/webroot as your DOCUMENT_ROOT.

    0 讨论(0)
  • 2020-11-28 05:41

    The answer is that there are 3 different .htaccess files:

    /var/www/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>
    

    /var/www/app/.htaccess

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

    /var/www/.htaccess

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

    It's been my fault, everything is listed on the CakePHP site. Thanks to everyone!

    0 讨论(0)
  • 2020-11-28 05:48

    The correct .htaccess is the default:

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

    You have to add this in "/etc/apache2/sites-enabled/default":

    <Directory /var/www>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      allow from all
    </Directory>
    

    if section already exists change AllowOverride None to AllowOverride All

    0 讨论(0)
提交回复
热议问题