.htaccess 子域重定向到一个特定文件夹 - CakePHP 应用程序
我正在尝试为我的应用程序设置一个子域,因为我不希望管理代码与常规用户代码混合到相同的文件夹中。我在 PHPfog 服务器上使用 CakePHP,所以我只能使用 .htaccess 来创建子域。我已启用通配符子域支持。
这是我的文件夹结构:
app
app-admin
cake
plugins
vendors
index.php
.htaccess
“app”文件夹是“普通用户”站点代码所在的位置。当然,“app-admin”文件夹将供管理员使用。
我正在尝试获取一个特定的重写规则,该规则会将所有前往 admin.mydomain.com 的内容重定向到“app-admin”文件夹。应忽略所有其他子域(发送到“app”文件夹)。
CakePHP 应用程序中的库存 .htaccess 文件如下所示:
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
现在我正在尝试此操作,但没有运气:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^admin[NC]
RewriteRule ^$ app-admin/webroot/ [L]
RewriteCond %{HTTP_HOST} ^admin[NC]
RewriteRule (.*) app-admin/webroot/$1 [L]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
任何帮助实现此功能的帮助将不胜感激。
I'm trying to set up a subdomain for my application because I don't want admin code to be mixed into the same folders as regular user code. I'm using CakePHP on a PHPfog server, so I can only use .htaccess to create the subdomain. I have enabled wildcard subdomain support.
Here is my folder structure:
app
app-admin
cake
plugins
vendors
index.php
.htaccess
The 'app' folder is where the "normal user" site code is located. The "app-admin" folder will be for admins, of course.
I'm trying to get a specific rewrite rule that will redirect anything going to the admin.mydomain.com, to the "app-admin" folder. All other subdomains should be ignored (sent to the 'app' folder).
The stock .htaccess file in a CakePHP app looks like this:
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
Right now I'm trying this with no luck:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^admin[NC]
RewriteRule ^$ app-admin/webroot/ [L]
RewriteCond %{HTTP_HOST} ^admin[NC]
RewriteRule (.*) app-admin/webroot/$1 [L]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
Any help to get this functioning would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您能否将此代码放入您的 .htaccess 中并重试:
另外请报告更多详细信息,例如哪些 URL 不起作用。值得查看的地方是 apache error.log 和访问日志。
Can you put this code in your .htaccess and try again:
Also please report some more details like what URLs are not working. Good place to look at would be apache error.log and access log.