简体   繁体   English

重定向而不更改网址htaccess

[英]Redirect without changing Url htaccess

I'm wondering if this is possible - I have projects structured like: 我想知道这是否可能-我的项目结构如下:

www.mydomain.com points to MyFolder on server. In MyFolder i have 3 App Folders eg MyFolder/App1, MyFolder/App2..

Each of these are 3 different web applications. 这些都是3个不同的Web应用程序。 Url of domain is www.mydomain.com Is it possible, that, when url user go to mydomain.com, it automatically redirect to mydomain.com/App1 but without url change visible to user (in browser it will still be mydomain.com)? 域的网址为www.mydomain.com是否有可能,当url用户转到mydomain.com时,它会自动重定向到mydomain.com/App1,但用户看不到url更改(在浏览器中仍为mydomain.com )? I can not point domain to MyFolder/App1 because that way app2 is not accessible. 我无法将域指向MyFolder / App1,因为无法访问app2。 My solution is that app1 becomes a root which contains app2,app3 etc folder but thats just to messy edit: question clarification 我的解决方案是app1成为包含app2,app3等文件夹的根目录,但这仅是混乱的编辑:问题澄清

You should be able to use this code here. 您应该可以在这里使用此代码。

RewriteEngine on
#ignore App1 and App2 and interally Rewrite to /App
RewriteCond %{REQUEST_URI} !(App1|App2) [NC]
RewriteRule ^(.*)$ /App/$1 [L]

Yes, you should be able to do it in your .htaccess file like this (untested code): 是的,您应该可以在.htaccess文件中执行以下操作(未经测试的代码):

RewriteCond %{HTTP_HOST} ^example.com/App
RewriteRule ^(.*) http://www.example.com/App1 [P] 

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

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