Cakephp 3.0: rewrite .htaccess rule to allow new folder access?

时间:2015-07-28 17:03:14

标签: php .htaccess cakephp mod-rewrite cakephp-3.0

I'm using cakephp 3.0 and I'm facing a problem. I upload my site on server on root level, where I place some demos which I can use for other purpose. Now issue is that when I access my site with domain name then it is working fine. But if I give any folder name which is placed on root level which is not the part of my site and is indiviual part of site. Then it is not accessible.

Below is my folder structure of root level

enter image description here

There a single folder named gallery is a demo. How can I allow this folder to access like this http://hostname.com/gallery or any other new folder.

My .htaccess file code is:

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

Please help me on this issue which is more appreciable. Thanks in advance.

2 个答案:

答案 0 :(得分:1)

Just move your "gallery" folder under "webroot".

答案 1 :(得分:0)

试试这个,它为我工作。

在&#34; gallary&#34;中创建.htaccess文件包含以下内容的文件夹。

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
</IfModule>

并尝试使用网址http://server_name.com/gallary

您可以访问该文件夹和文件。

感谢。