setting up a subdomain to point to a folder using

2019-09-10 15:38发布

hi guys I've build a website using the zend framework and using clean urls - however I need to set up a subdomain such that it points to only one folder on my website i.e I want the subdomain admin.mysite.com to point to mysite.com/admin and I wanna do it using my htaccess file

EDIT -------

This is my htaccess file:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule (.*) http://www.mysite.com/$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php
RewriteRule !\.(js|ico|gif|jpg|png|css|htm|html)$ index.php 

RewriteCond %{REQUEST_URI} !^/admin
RewriteCond %{HTTP_HOST} ^admin
RewriteCond %{REQUEST_URI} !^/admin
RewriteRule ^(.*)$ admin/$1 [L]


AddType text/css .css
AddHandler php5-script .php

标签: .htaccess
3条回答
放我归山
2楼-- · 2019-09-10 15:39

on subdomain admin.mysite.com use directive Redirect.

Redirect permanent / http://mysite.com/admin

Or you can use proxy:

ProxyPass / http://mysite.com/admin
ProxyPassReverse / http://mysite.com/admin
ProxyPreserveHost on
查看更多
兄弟一词,经得起流年.
3楼-- · 2019-09-10 15:55

Try something like this above your existing URL rerwites:

RewriteCond %{HTTP_HOST} ^admin
RewriteCond %{REQUEST_URI} !^/admin
RewriteRule ^(.*)$ admin/$1 [L]

Edit: To prevent it from being interpreted as a Zend Frameowrk controlleradd the following above your existing RewriteConds to prevent it from transforming your admin URLs:

RewriteCond %{REQUEST_URI} !^/admin

And I think that should take care of everything.

Edit: Your .htaccess file should look more like the following, though I don't think any of the changes would relate to your 403 error, but maybe we'll get lucky. If not, I'll keep thinking of what might cause that.

RewriteEngine on

RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule (.*) http://www.mysite.com/$1 [L,R=301]

# Don't rewrite requests on admin subdomain to the Zend Framework handler
RewriteCond %{HTTP_HOST} !^admin
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php

RewriteCond %{HTTP_HOST} !^admin
RewriteRule !\.(js|ico|gif|jpg|png|css|htm|html)$ index.php [L]

RewriteCond %{HTTP_HOST} ^admin
RewriteCond %{REQUEST_URI} !^/admin
RewriteRule ^(.*)$ admin/$1 [L]

AddType text/css .css
AddHandler php5-script .php
查看更多
仙女界的扛把子
4楼-- · 2019-09-10 16:02

On admin.mysite.com "/" you can symlink to "/admin"

查看更多
登录 后发表回答