Hide domain directory using htaccess or router in cakephp

2

I'm having a hard time creating a configuration in .htaccess to hide a folder from my site.

My domain has the following structure: www.site.com.br/cake, where are the files and folders related to the project. I want to hide the / cake directory, showing only the domain on all pages, www.site.com.br /

The current .htaccess file has the following configuration:

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

I've tried:

RewriteCond %{HTTP_HOST} ^(www.)?site.com.br$
RewriteCond %{REQUEST_URI} !^/cake/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /
RewriteCond %{HTTP_HOST} ^(www.)?site.com.br/$
RewriteRule ^(/)?$ cake/index.php [L]

And it does not work, it gives 500 error. Can you help me?

    
asked by anonymous 03.07.2015 / 15:26

1 answer

2

What you want is not necessarily to hide the directory, but rather direct access from the root folder to from the cake folder.

Create the .htaccess file in the root folder and add the following content:

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteBase /
   RewriteRule ^(?!cake/)(.*)$ cake/$1 [QSA,L]
</IfModule>

If the error 500 is happening you probably will not have modrewrite enabled, so open the httpd.conf file and look for the line that contains something like:

LoadModule rewrite_module modules/mod_rewrite.so

It's likely to be commented on:

#LoadModule rewrite_module modules/mod_rewrite.so

Remove the hash (#) save the file and restart Apache.

    
03.07.2015 / 17:06