Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Apache mod_重写同一目录下的特定域_Php_Apache_Mod Rewrite_Yii - Fatal编程技术网

Php Apache mod_重写同一目录下的特定域

Php Apache mod_重写同一目录下的特定域,php,apache,mod-rewrite,yii,Php,Apache,Mod Rewrite,Yii,我已经使用PHP&Yii框架编写了一个网站,在那里我有一个.htaccess文件,其中有一个mod_rewrite语句来使用干净的URL: Options +FollowSymLinks IndexIgnore */* RewriteEngine on RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d Rewri

我已经使用PHP&Yii框架编写了一个网站,在那里我有一个
.htaccess
文件,其中有一个
mod_rewrite
语句来使用干净的URL:

Options +FollowSymLinks
IndexIgnore */*

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
例如,我使用这个域:
www.example.com
&
popstan.net
,这些域的URL重写工作就像在梦中一样

但是,我现在正在创建一个博客,通过我的Yii控制器,我可以访问博客文章、博客类别和单个博客文章:

  • -列出所有新文章
  • -列出特定类别的文章
  • -预览单个博客文章
现在,我希望使用这个博客,但在域:
下,并维护这些URL结构,我不希望将我的网站复制到两个单独的目录(即博客目录)上

是否可以使用
mod_rewrite
重写域的URL,但要从父目录获取URL?

您只需:

1) 创建一个指向同一目录的
blog.example.com

2) 在Yii配置中定义相应的url规则,例如:

'http://blog.example.com/<action:\w+>/<param:\w+>'=>'/blog/<action>',
'http://blog.example.com/'=>'/blog/index',
'http://blog.example.com//“=>”/blog/”,
'http://blog.example.com/“=>”/blog/index',

您无需修改
.htaccess

此[链接][1]将对您有所帮助。这是关于apache虚拟主机的。。。[1]: