开发者

.htaccess subdomain redirect to one specific folder - CakePHP App

开发者 https://www.devze.com 2023-03-09 05:37 出处:网络
I\'m trying to set up a subdomain for my application because I don\'t want admi开发者_C百科n code to be mixed into the same folders as regular user code.I\'m using CakePHP on a PHPfog server, so I can

I'm trying to set up a subdomain for my application because I don't want admi开发者_C百科n 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.


Can you put this code in your .htaccess and try again:

Options +FollowSymlinks -MultiViews
RewriteEngine on  

RewriteCond %{HTTP_HOST} ^admin\. [NC]  
RewriteRule ^(?!app-admin/) app-admin/webroot%{REQUEST_URI} [L,NC]

RewriteRule ^(?!app/) app/webroot%{REQUEST_URI} [L,NC]

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号