2012-01-11 85 views
0

比方说,我的根域名是main.com和我有两个插件域:addon1.comaddon2.com多个插件域,一个htaccess文件

我的剧本是早就准备好了,我可以看到我的网站是这样的:

www.main.com/show.php?domain=addon1.com 

但是,我希望通过自己的域上显示的网站内容。我的意思是当我打开addon1.com时,我想看到输出为show.php?domain = addon1.com。同时这两个域添加附加域和其目录是:

main.com/addon1.com/ 
    main.com/addon2.com/ 

我写了一htaccess文件的根文件夹(main.com/.htaccess)

Options +FollowSymLinks 
    RewriteEngine On 

    RewriteCond %{HTTP_HOST} ^www\.addon1\.com$ [NC] 
    RewriteRule ^(.*)$ /show.php?domain=addon1.com&$1 

    RewriteCond %{HTTP_HOST} ^www\.addon2\.com$ [NC] 
    RewriteRule ^(.*)$ /show.php?domain=addon2.com&$1 

但我发现了500间隔错误。有什么建议?

在此先感谢。

回答

0

您的规则正在循环。 /show.php将通过重写引擎返回并无限循环。您需要添加的条件,使他们不循环:

RewriteCond %{HTTP_HOST} ^www\.addon1\.com$ [NC] 
RewriteCond %{REQUEST_URI} !^/show.php 
RewriteRule ^(.*)$ /show.php?domain=addon1.com&$1 

RewriteCond %{HTTP_HOST} ^www\.addon2\.com$ [NC] 
RewriteCond %{REQUEST_URI} !^/show.php 
RewriteRule ^(.*)$ /show.php?domain=addon2.com&$1 
+0

感谢您的回答。但是这是尝试加载** main.com/addon1.com/show.php **,show.php位于根文件夹(main.com/show.php)中。 – Deniz 2012-01-11 20:53:17

0

你需要包括“RewriteBase”助阵。

# tell mod_rewrite to activate and give base for relative paths 
    Options +FollowSymLinks 
    RewriteEngine on 
    RewriteBase /

# for the active site in hosting root folder, 
# tell it not to look for a subfolder by skipping next rule 
    RewriteCond %{HTTP_HOST} ^(www\.)?main\.com [NC] 
    RewriteRule ^(.*)$   - [S=1] 

# the domain-name = sub-folder automation 
# thus addon-domain.com in /addon-domain(\.com)?/ 
    RewriteCond %{HTTP_HOST} ([^.]+)\.com 
    RewriteCond %{REQUEST_URI} !^/%1 
    RewriteRule ^(.*)$   %1/$1 [L] 

# to answer your question swap the above 
# domain-name = sub-folder automation for this rule 
    RewriteCond %{HTTP_HOST} ([^.]+)\.com$ [NC] 
    RewriteCond %{REQUEST_URI} !^/show.php 
    RewriteRule ^(.*)$   /show.php?domain=%1&$1 [L] 
# although, the above line may require this instead 
    RewriteRule .    main.com/show.php?domain=%1&$1 [L]