简体   繁体   English

htaccess规则重定向到动态子域

[英]htaccess rule to redirect to a dynamic subdomain

we manage over 70 properties and each of their websites runs from the same php code with a database controlling the differences. 我们管理着70多个网站,每个网站都使用相同的php代码运行,并带有控制差异的数据库。 I need to write a redirect for a specific occasion and I don't know how to create variables in .htaccess. 我需要为特定情况编写重定向,并且我不知道如何在.htaccess中创建变量。

for example: http://www.firstproperty.com/banquet becomes http://banquet.firstproperty.com and http://www.secondproperty.com/banquet becomes http://banquet.secondproperty.com 例如: http : //www.firstproperty.com/banquet变成http://banquet.firstproperty.com,http://www.secondproperty.com/banquet变成http://banquet.secondproperty.com

I am not sure if I should do this as a "redirect" or a "RewriteCond/RewriteRule" 我不确定是否应该将其作为“重定向”或“ RewriteCond / RewriteRule”来执行

This is my .htaccess now ( it removes index.php from codeigniter friendly urls ) 这是我的.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]

Isnt that a subdomain? 那不是子域吗? in my opinion you should get into httpd.conf and not htaccess to manage that. 我认为您应该进入httpd.conf而不是htaccess来进行管理。 Or am i wrong? 还是我错了? wait a bit for further expertise comments in here. 请在这里稍等其他专业意见。 some work done here already it might help you out: how to create subdomains in apache(xampp) server? 已经在这里完成了一些工作,可能会对您有所帮助: 如何在apache(xampp)服务器中创建子域? hope it helps. 希望能帮助到你。

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM