【发布时间】:2016-04-11 08:03:35
【问题描述】:
我正在建立一个包含两个主要部分的网站,
所以我创建了两个子域:
web1.example.com web2.example.com
因为我正在使用 codeigniter 构建网站,所以我想重定向到 index.php 页面。这就是我所做的:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^web1.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/web1 [R=301,NC,L]
它按预期工作,但它将 URL 更改为 example.com/web1.. 有什么办法可以保留 url web1.example.com,但仍然重定向到 example.com/web1?
我已经在使用 .htaccess 文件了:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
当我输入 web1.example.com 时,实际要执行的 url 应该是: example.com/web1,要执行的文件是 index.php ..
【问题讨论】:
-
你期望的输出 URL 是什么
标签: php apache .htaccess codeigniter redirect