【问题标题】:htaccess rule to redirect to a dynamic subdomainhtaccess 规则重定向到动态子域
【发布时间】:2013-02-19 21:11:49
【问题描述】:

我们管理超过 70 家酒店,他们的每个网站都使用相同的 php 代码运行,并使用数据库控制差异。我需要为特定场合编写重定向,但我不知道如何在 .htaccess 中创建变量。

例如: http://www.firstproperty.com/banquet 变为 http://banquet.firstproperty.comhttp://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


【解决方案1】:

那不是子域吗?在我看来,你应该进入 httpd.conf 而不是 htaccess 来管理它。还是我错了?在这里等待进一步的专业知识。已经在这里完成了一些工作,它可能会对您有所帮助:how to create subdomains in apache(xampp) server? 希望对您有所帮助。

NameVirtualHost 127.0.0.1:80
<VirtualHost *:80>
<Directory /banquet>
    Options FollowSymLinks Indexes
    AllowOverride All
    Order deny,allow
    allow from All
</Directory>
ServerName banquet.firstproperty.com/
ServerAlias www.banquet.firstproperty.com/
DocumentRoot /banquet
</VirtualHost>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-11
    • 2016-11-10
    • 2012-05-19
    相关资源
    最近更新 更多