Php htaccess在重定向后从url隐藏子目录

Php htaccess在重定向后从url隐藏子目录,php,.htaccess,server,url-redirection,Php,.htaccess,Server,Url Redirection,我在本地服务器上运行了相同的应用程序—一个在“localhost”中,另一个在“localhost/bss/”中。我的域名端口转发给他们。所以www.domain.com:1111和sub.domain2.info:1111指向localhost。现在它们都显示localhost。我需要将sub.domain2.info:1111(localhost)重定向到sub.domain2.com:1111/bss/(localhost/bss),但不想看到“/bss” localhost中的My.ht

我在本地服务器上运行了相同的应用程序—一个在“localhost”中,另一个在“localhost/bss/”中。我的域名端口转发给他们。所以www.domain.com:1111和sub.domain2.info:1111指向localhost。现在它们都显示localhost。我需要将sub.domain2.info:1111(localhost)重定向到sub.domain2.com:1111/bss/(localhost/bss),但不想看到“/bss”

localhost中的My.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服务器来实现这一点。如果您在本地环境中工作,也可以尝试使用虚拟主机 你能为你的子域试试这个吗

RewriteEngine on

RewriteCond %{HTTP_HOST} ^sub\.domain2\.com$
RewriteCond %{REQUEST_URI} !^/bss
RewriteRule ^(.*)$ /bss/$1 [L]
通过查看您可以设置的评论来添加此内容


顺便说一下,我不明白你为什么在域名中使用这些端口

嗨,谢谢你的回复。这是一个转发的公共端口,所以我不需要输入“:1111”like.com:1111$”吗?问题是我尝试了使用或不使用端口。在子目录(localhost/bss/)内的.htaccess中添加了该代码,但它仍然显示sub.domain.com:1111/bss/和virtualhost edit在我的centos服务器中由于某种原因无法工作。我在centos与xampp合作。