Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controlling redirection of CakePHP with .htaccess

I’ve installed cakePHP on Windows7+Apache2.2 and tried blog tutorial.

Now I’ve been confusing redirection control with .htaccess.

I’ve followed instruction of tutorial for setting .htaccess.

htdocs
  .htaccess
  app
    .htaccess
     webroot
        .htaccess

Eache .htaccess files are below.

[under htdocs]

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

[under app]

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

[under wabroot]

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

But error happens,here is message in error.log

client denied by server configuration: :/Apache2.2/htdocs/app/webroot/.htaccess

What’s wrong ?

This tutorial app uses following URLs.

http://mydomain/posts/index   // show index page
http://mydomain/posts/view/3  //show an article selected from index(3 means ID number)
http://mydomain/posts/add     //show a page for posting new articl
http://mydomain/posts/edit/3   //show a page for e
http://mydomain/posts/delete/3   //delete an article selected from index 

.htaccess control redirection normally when URLs are /index and /view/3.

But if URLs are /add ,/edit/3 and /delete apache doesn’t redirect them to index.php.

Actually operation for articles with add ,edit and delete are processed successfully.

And add,edit and delete use POST method

I guess if its method is POST redirection will be failure.

like image 238
user1345414 Avatar asked Nov 11 '22 09:11

user1345414


1 Answers

Your folder structure is not seems good... You have to create a project name under htdocs and copy Cakephp files to that folder. Like-

htdocs
   --myapplication
      .htaccess
     -- app
          .htaccess
     -- webroot
          .htaccess
like image 96
Fazal Rasel Avatar answered Nov 15 '22 05:11

Fazal Rasel