Site opens in webroot folder

Asked

Viewed 185 times

-2

The site I’m putting online is presenting http://mysite.com/app/webroot/ every time www.mysite.com on the way to access it. However I wanted it to just go to http://mysite.com/, where is the view Home.ctp.

I’m using Cake version 2.4.4.

htaccess

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule    ^$ app/webroot/    [L]
RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>
  • How is your file .htaccess?

  • @I edited the question.

  • Now I need your file apache\conf\httpd.conf.

  • @Ciganomorrisonmendez I don’t know yet access to httpd.conf from the server, but the rewrite mod is working, the cake installation at least said so.

  • Have you checked the file routes.php? See if it’s like this: Router::connect( '/', array('controller' => 'pages', 'action' => 'home') );

  • @Igormartins Yes and the route is correct.

Show 1 more comment

1 answer

1


There are two ways to solve this:

1) Cpanel/Plesk

Create a redirect of all requests with http://www for http://push....

For example. na Bluehost you do it on this page (it’s practically the same operation on all Cpanels).

inserir a descrição da imagem aqui

What are you must select in this case it is your domain, and not let selected "All Domains", otherwise all requests on this server will be redirected to the URL you entered below.

Other than that, down below there are some radio Buttons, which you select if you want to redirect only when the URL has www, in both cases or do not redirect the www.


2) . htaccess

In his .htaccess root (the first), do the following:

<IfModule mod_rewrite.c> 
   RewriteEngine On
   RewriteBase /
   RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
   RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

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

Choose one of the above ways and test.

Any questions, leave a comment below.

  • The home.ctp this in the folder View\Home\, and the route is Router::connect('/', array('controller' => 'home', 'action' => 'home'));. htaccess is also in the right places.

  • I understand what the problem is.... I’m already going to edit the question.

  • I used the second option and it worked wonders. Thank you very much!

  • Needing we are there.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.