How to write rewrite .htaccess rule to allow new folder access?

北战南征 提交于 2019-12-25 04:19:19

问题


The current cakephp .htaccess rules reroute all incoming requests to the app/webroot folder. See following rule:

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

At the moment I still developing and I have created a "site" folder in the cakephp root folder. But when I try to access the folder from the browser I get redirected to due the cakephp rewrite. I've done some research but I can't seem to figure out the required regular expression to change the rule. How do I modify/append the .htaccess folder to allow access to the 'site' folder.

Regards


回答1:


An alternative to modifying the .htaccess rules is to move your site folder to app/webroot/.




回答2:


You can do like this

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/path/to/cake_root/site
RewriteRule    ^$ app/webroot/    [L]
RewriteCond %{REQUEST_URI} !^/path/to/cake_root/site
RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

Regards



来源:https://stackoverflow.com/questions/5538181/how-to-write-rewrite-htaccess-rule-to-allow-new-folder-access

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!