Remove index.php from cakephp url

how to remove index.php from cakephp url? To access the folder with my formats, I have to specify url: http: //localhost/cake_1_2/index.php/forms .

How to remove this index.php?

I removed .htaccess from the folders as mentioned in core.php and uncommented the App.baseUrl line. However, I cannot view the page without index.php in the url.

+3
source share
6 answers

If you use CakePHP with mod_rewrite (to get pretty URLs), you can create new folders in WEBROOTand easily access files.

Example:

Site/webroot/forms/form.php = http://www.sitename.com/forms/form.php

CakePHP mod_rewrite WEBROOT NOT index.php.

-, , .

+2

CakePHP Install guide mod_rewrite. Apache URL- . Apache, URL-.

+1

, , .

  • , root, app, webroot .htaccess.

  • apachee :

    <Directory /> 
     Options FollowSymLinks   
     AllowOverride All#   
     Order deny,allow#   
     Deny from all
    </Directory>
    
  • :

    LoadModule rewrite_module libexec/apache2/mod_rewrite.so
    

apache,

+1

, index.php. httpd.conf. , , .htaccess :/.htaccess,/app/.htaccess /app/webroot/.htaccess

httpd.conf :

# Leave this area alone, CakePHP docs are wrong
<Directory /> 
   Options FollowSymLinks
   AllowOverride None
   Order deny,allow
   Deny from all
</Directory>

# Match this area
<Directory "/SomePath/app/webroot"> 
  Options Indexes FollowSymLinks MultiViews
  AllowOverride All   # Turn AllowOverride All on here
  Order allow,deny
  Allow from all
</Directory>

, : http://localhost/about/

!

+1

mod . , URL . .

0

, ? mod_rewrite?

mod_rewrite , htaccess , index.php , , , core.php.

App.baseUrl:

Configure::write('App.baseUrl', env('SCRIPT_NAME'));

Here's how I fixed this problem (and a few others with redirects) by commenting out the following line from core.php:

// Configure::write('App.baseUrl', env('SCRIPT_NAME'));

or cake 3+ in config / app.php

//'baseUrl' => env('SCRIPT_NAME') 
0
source

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