【发布时间】:2019-03-23 03:03:15
【问题描述】:
在我的根目录中,我有太多不同项目的子文件夹。目前我正在使用 cakephp,我必须设置 .htaccess 文件才能访问 index.php。
这是我创建的不同 .htaccess 文件:
在lampp的htdocs中:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ carte_drin/app/webroot/ [L]
RewriteRule (.*) carte_drin/app/webroot/$1 [L]
</IfModule>
在 carte_drin cakephp 项目文件夹中:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /carte_drin/
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
在app文件夹中
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /carte_drin/app/
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
在 webroot 文件夹中:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /carte_drin/app/webroot/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
我的问题是当我尝试访问另一个项目时,我被定向到 carte_drin 项目。我相信 htdocs 中 .htaccess 文件的重写规则会导致问题。
我需要一种方法在根目录的每个项目文件夹中创建 .htaccess 点。
【问题讨论】:
-
您应该为您的个人项目设置适当的虚拟主机......
-
你能再解释一下吗?
-
现在您正在浏览器中通过
http://localhost/project1/、http://localhost/project-xy/等方式访问它,对吧?相反,您应该进行设置,以便每个项目在其自己的域名下可用,该域的文档根目录直接指向相应的项目文件夹。然后,您应该能够使用这些框架附带的“默认”重写,而无需进行手动调整。 dasunhegoda.com/what-how-to-apache-virtual-host/444
标签: php .htaccess mod-rewrite cakephp