建立一个子域名指向到一个文件夹中使用的htaccess [英] setting up a subdomain to point to a folder using htaccess
问题描述
大家好我已经使用Zend框架,使用清洁的URL建立一个网站 - 但我需要建立一个子域,使其指向我的网站上,即只有一个文件夹我想要的子域名 admin.mysite.com
来点 mysite.com/admin
和我想要做的用我的htaccess的文件时,它
编辑-------
这是我的htaccess文件:
RewriteEngine叙述上
的RewriteCond%{HTTP_HOST} ^ mysite.com [NC]
重写规则(。*)http://www.mysite.com/$1 [L,R = 301]
的RewriteCond%{} REQUEST_FILENAME!-f
重写规则。*的index.php
!重写规则\(JS | ICO | GIF | JPG | PNG | CSS | HTM | HTML)$的index.php
的RewriteCond%{REQUEST_URI}!^ /管理
的RewriteCond%{HTTP_HOST} ^管理
的RewriteCond%{REQUEST_URI}!^ /管理
重写规则^(。*)$管理/ $ 1 [L]
将AddType文本/ CSS的CSS
AddHandler的PHP5脚本的.php
试试上面的现有URL rerwites是这样的:
的RewriteCond%{HTTP_HOST} ^管理
的RewriteCond%{REQUEST_URI}!^ /管理
重写规则^(。*)$管理/ $ 1 [L]
编辑:以prevent它被跨preTED作为一个Zend Frameowrk controlleradd上述现有的的RewriteCond
取值如下以$ P $从改变你的管理网址pvent它:
的RewriteCond%{REQUEST_URI}!^ /管理
和我认为应该照顾一切。
编辑:您的.htaccess
文件应该看起来更像以下,虽然我不的认为的任何的变化会涉及到你的403错误,但也许我们会得到幸运。如果没有,我会保持什么可能会导致思维。
RewriteEngine叙述上
的RewriteCond%{HTTP_HOST} ^ mysite.com [NC]
重写规则(。*)http://www.mysite.com/$1 [L,R = 301]
#不要重写Zend框架处理程序上的管理子域名的请求
的RewriteCond%{HTTP_HOST}!^管理
的RewriteCond%{} REQUEST_FILENAME!-f
重写规则。*的index.php
的RewriteCond%{HTTP_HOST}!^管理
!重写规则\(JS | ICO | GIF | JPG | PNG | CSS | HTM | HTML)$的index.php [L]
的RewriteCond%{HTTP_HOST} ^管理
的RewriteCond%{REQUEST_URI}!^ /管理
重写规则^(。*)$管理/ $ 1 [L]
将AddType文本/ CSS的CSS
AddHandler的PHP5脚本的.php
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
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 RewriteCond
s 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
这篇关于建立一个子域名指向到一个文件夹中使用的htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!