简体   繁体   English

htaccess重定向后从网址隐藏子目录

[英]htaccess hide subdirectory from url after redirect

I have same application running in local server - one in 'localhost', another in 'localhost/bss/'. 我在本地服务器上运行了相同的应用程序-一个在“ localhost”中,另一个在“ localhost / bss /”中。 My domains port forwarded to them. 我的域端口已转发给他们。 So www.domain.com:1111 and sub.domain2.info:1111 points to localhost. 因此www.domain.com:1111和sub.domain2.info:1111指向本地主机。 Now both of them showing localhost. 现在他们两个都显示localhost。 I need to redirect sub.domain2.info:1111 (localhost) to sub.domain2.com:1111/bss/ (localhost/bss) but dont want to see '/bss' 我需要将sub.domain2.info:1111(localhost)重定向到sub.domain2.com:1111/bss/(localhost / bss),但不想看到'/ bss'

My .htaccess in localhost is currently like this - 我在本地主机的.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]

Nothing particular in .htaccess in localhost/bss - 在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

I would highly appreciate your response. 非常感谢您的回复。 Tried a few but nothing seems to work! 尝试了一些,但似乎无济于事!

Assuming that you are using Apache Server for achieving this. 假设您正在使用Apache Server实现此目的。 If you are working on local environments you can try out with Virtual Hosts also Can you try this for your Subdomain 如果您在本地环境中工作,则可以尝试使用虚拟主机,也可以在子域中尝试使用吗?

RewriteEngine on

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

Adding this by seeing your comment you can set up virtualhosts in linux 通过查看评论添加此内容,您可以在linux中设置虚拟主机

By the way, I didn't understand why you using these ports in domain names 顺便说一句,我不明白为什么您在域名中使用这些端口

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM