How to config .htaccess files of CakePHP in WampServer?

前端 未结 4 603
灰色年华
灰色年华 2021-01-13 09:07

I\'m absolutely confused about what I must do to run my sample in CakePHP...

I\'m using WAMP Server and it is located in \"C:/program files/wamp/\" and I use anothe

相关标签:
4条回答
  • 2021-01-13 09:55

    use

      RewriteRule ^posts/(.*)  index.php/posts/index
    
    0 讨论(0)
  • 2021-01-13 10:01

    I actually got the same issue as you, but I don't remember how I solved it.

    What I can assure you it's not a .htaccess issue, but a configuration error of Apache.

    I think the part I modified was this one.

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

    Note how I commented some lines. Altough I can't confirm this, since I don't have the default configuration file.

    0 讨论(0)
  • 2021-01-13 10:02

    I had same issue and here is solution that worked for me

    this is my cakephp.conf in wamp server

    Alias /cakephp "d:/wamp/apps/cakephp/app/webroot" 
    
    <Directory "d:/wamp/apps/cakephp/app/webroot">
       Options FollowSymLinks
       AllowOverride all
       Require local
    </Directory>
    

    This is .htaccess file in /cakephp (not changed anything)

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

    This is .htaccess file in /cakephp/app (not changed anything)

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

    This is .htaccess file in /cakephp/app/webroot (changed)

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

    I just added line this line

    RewriteBase /cakephp
    

    After this I was able to launch url localhost/cakephp/index.php/posts/index

    Hope this will help you to get started with CakePhp using WAMP Server

    0 讨论(0)
  • 2021-01-13 10:03
    1. Right click on the WAMP icon on your task bar
    2. Then Hover over Apache Modules
    3. Scroll down and make sure rewrite_module is ticked
    0 讨论(0)
提交回复
热议问题