簡體   English   中英

htaccess規則重定向到動態子域

[英]htaccess rule to redirect to a dynamic subdomain

我們管理着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]

那不是子域嗎? 我認為您應該進入httpd.conf而不是htaccess來進行管理。 還是我錯了? 請在這里稍等其他專業意見。 已經在這里完成了一些工作,可能會對您有所幫助: 如何在apache(xampp)服務器中創建子域? 希望能幫助到你。

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