繁体   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