亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

mod_rewrite 多域名

mod_rewrite 多域名

PHP
忽然笑 2022-12-03 11:02:56
所以我在一臺服務器上有 2 個域名 2 個不同的站點 我在一個域名上有 mod-rewrite 我想只為一個域名工作但是當我上傳 .htaccess 文件時 1 域名工作得很好但是其他站點/域名顯示 Not FoundThe requested URL was not found on this server.Additionally, a 404 Not Found _error_ was encountered while trying to use an ErrorDocument to handle the request.如果我刪除 mod 重寫文件,第二個站點可以工作并顯示,但第一個站點需要 mod 重寫才能工作,有什么方法可以將 mod 重寫設置為僅針對一個域名運行?只是想添加主域名在根目錄中,第二個域名在根目錄中的文件中,所以我希望所有條件都適用于根目錄中的域名 1 但不適用于位于 a 中的域名 2根目錄下的文件夾。當我訪問域名 2 時,出現 404 錯誤。    options -multiviews    options All -Indexes    <IfModule mod_rewrite.c>    RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} mydomainname.com$ [NC]    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> 
查看完整描述

1 回答

?
Qyouu

TA貢獻1786條經驗 獲得超11個贊

RewriteConds 僅適用于緊隨其后的一個RewriteRule,因此您必須在每個 RewriteRule 之前重復它們。


在這里使用否定模式可能更有意義 - 檢查主機名是否不是 mydomainname.com,然后通過使用 [L] 標志簡單地說“好的,我們在這里完成”的規則來遵循。


RewriteEngine On

RewriteBase /

# check if the host name was not mydomainname.com

# pattern anchored at the start using ^ as well here, so that notmydomainname.com

# would not be matched as well, and the . escaped

# whole thing negated, by putting ! in front of it

RewriteCond %{HTTP_HOST} !^mydomainname\.com$ [NC]

# match absolutely anything with the .

# don’t do any actual rewriting, by using - as the substitution

# [L] flag to say, that’s it, we are done with the rewriting here

RewriteRule . - [L]

# … rest of your rules follow here

RewriteCond %{SCRIPT_FILENAME} !-d

RewriteCond %{SCRIPT_FILENAME} !-f

# …


查看完整回答
反對 回復 2022-12-03
  • 1 回答
  • 0 關注
  • 100 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號