url通过htaccess重定向

时间:2011-01-12 04:17:35

标签: .htaccess

我在同一台服务器上托管了两个站点,并且我管理它们为每个域提供文件夹。我想网站来了

example.com/example
example1.com/example1

我想来

example.com and example.com 

我知道htaccess url重定向可以做到这一点,但我对此不太了解。 如果有关于php正则表达式的教程请告诉我。 一些帮助是可观的。

编辑 我通过将.htaccess文件放在root中并写入:

来解决这个问题
RewriteEngine On
#for example.com
RewriteCond %{HTTP_HOST}  example.com$ [NC]
RewriteCond %{REQUEST_URI} !^/example/.*$
RewriteRule ^(.*)$  /example/$1 [L]

当我点击example.com时,现在工作正常。它访问文件夹/示例。但我在某个领域遇到了问题。我使用codeigniter,我也必须重定向其请求,以便它不显示

example.com/example/index.php/controller/

我想表明这一点:

example.com/controller/
希望有些专家可以提供帮助。

1 个答案:

答案 0 :(得分:1)

.htaccess网址重定向设置为主目录中的文件,您的代码可能如下所示:

 # These redirects should do the trick :-)
 Redirect example.com/example http://www.example.com
 Redirect example.com/example1 http://www.example.com
相关问题