【发布时间】:2013-02-19 21:11:49
【问题描述】:
我们管理超过 70 家酒店,他们的每个网站都使用相同的 php 代码运行,并使用数据库控制差异。我需要为特定场合编写重定向,但我不知道如何在 .htaccess 中创建变量。
例如: http://www.firstproperty.com/banquet 变为 http://banquet.firstproperty.com 和 http://www.secondproperty.com/banquet 变为 http://banquet.secondproperty.com
我不确定我应该将其作为“重定向”还是“RewriteCond/RewriteRule”
这是我现在的 .htaccess(它从 codeigniter 友好的 url 中删除 index.php)
DirectoryIndex index.php
redirect /joinTeam.php /index.php/prop/join_team
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]
【问题讨论】:
-
在应用程序级别管理重定向不是更容易吗? (即检查并重定向 index.php)
-
不是这种情况。 CodeIgniter 的主站点 (www.firstproperty.com) 是与宴会应用程序不同的应用程序。由于我从 URL 中获取 propertyNumber,因此我需要将“firstproperty”部分放在到达宴会应用程序的 URL 中。
标签: php .htaccess codeigniter