http访问仅限1个域名

时间:2017-02-15 04:48:12

标签: php html

所以我在1个主机方案上有大量的域名,但在我的根目录中有一个主域名我正在使用http acess

options -multiviews
options All -Indexes
<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteCond %{SCRIPT_FILENAME} !-d
   RewriteCond %{SCRIPT_FILENAME} !-f
   RewriteRule ^home$ index.php
   RewriteRule ^dashboard$ dashboard.php
   RewriteRule ^advertiser$ advertiser.php
   RewriteRule ^add_campaign$ add_campaign.php
   RewriteRule ^edit_campaign$ edit_campaign.php
   RewriteRule ^stats$ view_statistics.php
   RewriteRule ^login$ login.php
   RewriteRule ^logout$ logout.php
   RewriteRule ^withdrawals$ withdrawals.php
   RewriteRule ^register$ register.php
   RewriteRule ^report$ report.php
   RewriteRule ^referrals$ referrals.php
   RewriteRule ^contact$ contact.php
   RewriteRule ^add_wallet$ add_wallet.php
   RewriteRule ^payment_page$ payment_page.php
   RewriteRule ^forgot_password$ forgot_password.php
   RewriteRule ^my_account$ my_account.php
   RewriteRule ^(admin)($|/) - [L]
   RewriteRule ^([A-Za-z0-9-]+)/?$ view_link.php?s=$1 [L]
   RewriteRule ^page_([^/]+)/?$ pages.php?slug=$1 [L]
</IfModule>

我的其他域名现在无法使用,因为它不会让我通过 domainname.com/folder 访问任何文件有没有办法为主要设置这些规则域名??

1 个答案:

答案 0 :(得分:0)

尝试添加与主域名匹配的RewriteCode。喜欢这个

options -multiviews
options All -Indexes
<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteCond %{HTTP_HOST} ^www.yourmaindomain.com$
   RewriteCond %{SCRIPT_FILENAME} !-d
   RewriteCond %{SCRIPT_FILENAME} !-f
   RewriteRule ^home$ index.php
   RewriteRule ^dashboard$ dashboard.php
   RewriteRule ^advertiser$ advertiser.php
   RewriteRule ^add_campaign$ add_campaign.php
   RewriteRule ^edit_campaign$ edit_campaign.php
   RewriteRule ^stats$ view_statistics.php
   RewriteRule ^login$ login.php
   RewriteRule ^logout$ logout.php
   RewriteRule ^withdrawals$ withdrawals.php
   RewriteRule ^register$ register.php
   RewriteRule ^report$ report.php
   RewriteRule ^referrals$ referrals.php
   RewriteRule ^contact$ contact.php
   RewriteRule ^add_wallet$ add_wallet.php
   RewriteRule ^payment_page$ payment_page.php
   RewriteRule ^forgot_password$ forgot_password.php
   RewriteRule ^my_account$ my_account.php
   RewriteRule ^(admin)($|/) - [L]
   RewriteRule ^([A-Za-z0-9-]+)/?$ view_link.php?s=$1 [L]
   RewriteRule ^page_([^/]+)/?$ pages.php?slug=$1 [L]
</IfModule>

然后只有在域匹配时才会运行重写规则。