我在我的主机服务器中使用域http://www.example.com/
有此路径,并且在目录home
中运行CakePHP。但是现在我希望我的 another_project_name
出现在 http://www.example.com/another_project_name/
的浏览器中。
这是我的结构:
/www
.htaccess
home/
.htaccess
webroot/
.htaccess
lib/
another_project_name/
这是我的/www/.htaccess
:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ home/webroot/ [L]
RewriteRule (.*) home/webroot/$1 [L]
</IfModule>
如何在/www/.htaccess
中配置.htaccess
文件以使我的another_project_name
工作?
尝试此
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule (another_project_name/.*) $1 [L] # adjust the regex to what you want.
RewriteRule (another_project_name.*) $1 [L] # adjust the regex to what you want.
RewriteRule ^$ home/webroot/ [L]
RewriteRule (.*) home/webroot/$1 [L]
</IfModule>
.htaccess文件应该像这样
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/?(another_project_name)/(.*)$
RewriteRule ^.*$ - [L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
对于多个目录
RewriteCond %{REQUEST_URI} ^/?(another_project_name1 | another_project_name2 | another_project_name3 )/(.*)$