簡體   English   中英

htaccess重定向后從網址隱藏子目錄

[英]htaccess hide subdirectory from url after redirect

我在本地服務器上運行了相同的應用程序-一個在“ localhost”中,另一個在“ localhost / bss /”中。 我的域端口已轉發給他們。 因此www.domain.com:1111和sub.domain2.info:1111指向本地主機。 現在他們兩個都顯示localhost。 我需要將sub.domain2.info:1111(localhost)重定向到sub.domain2.com:1111/bss/(localhost / bss),但不想看到'/ bss'

我在本地主機的.htaccess當前是這樣的-

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ /index.php/$1 [L]

Options -Indexes 

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)sub.domain2.info:1111$
RewriteRule (.*) /bss/$1 [R=301,L]

在localhost / bss中的.htaccess中沒有什么特別的-

RewriteEngine On
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ /index.php/$1 [L]

Options -Indexes

非常感謝您的回復。 嘗試了一些,但似乎無濟於事!

假設您正在使用Apache Server實現此目的。 如果您在本地環境中工作,則可以嘗試使用虛擬主機,也可以在子域中嘗試使用嗎?

RewriteEngine on

RewriteCond %{HTTP_HOST} ^sub\.domain2\.com$
RewriteCond %{REQUEST_URI} !^/bss
RewriteRule ^(.*)$ /bss/$1 [L]

通過查看評論添加此內容,您可以在linux中設置虛擬主機

順便說一句,我不明白為什么您在域名中使用這些端口

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM