简体   繁体   English

Apache2重定向foo

[英]Apache2 redirect foo

I searched a bit and because the folder I am trying to redirect is a subfolder of itself, it seems to be a challenge for me. 我搜索了一下,由于我要重定向的文件夹本身是其子文件夹,因此对我来说似乎是一个挑战。 Specifically here is the file system (using Apache2). 这里特别是文件系统(使用Apache2)。 I'm trying to do this with the root .htaccess file. 我正在尝试使用根.htaccess文件执行此操作。

Apache root is .../www/ Apache根目录是... / www /

I have a subfolder .../www/foo/www/... 我有一个子文件夹... / www / foo / www / ...

Within the foo/www/ are the files for this virtual site. 在foo / www /中是该虚拟站点的文件。 So for example (again file system) exists /www/foo/www/index.html 因此,例如(再次是文件系统)存在/www/foo/www/index.html

What I'm trying to achieve is a redirect from apache2's root so that request to: 我想要实现的是从apache2的根目录重定向,以便将该请求重定向至:

http://'host'/foo

arrive at /www/foo/www/ 到达/ www / foo / www /

Help is of course much appreciated. 帮助当然值得赞赏。

Add this rule in your /www/.htaccess file: 在您的/www/.htaccess文件中添加以下规则:

RewriteEngine On

RewriteRule ^((?!foo/www/).*)$ /foo/www/$1 [L,NC]

Sometimes I just hate certain sloppiness ... I'm quite guilty. 有时我只是讨厌某些草率的行为……我很内。

Let me say thank you to those that spent the time to try and help. 我要感谢那些花时间尝试和帮助的人。

Turns out from trying to make it work I had a 结果是我试图让它起作用

/www/foo/www
/www/Foo/www

when I discovered and correct this, the following worked fine: RedirectMatch 301 ^/foo/?$ /foo/www 当我发现并纠正此错误时,以下操作正常:RedirectMatch 301 ^ / foo /?$ / foo / www

although it does show the redirect in the browser URL. 尽管它确实在浏览器URL中显示了重定向。 It is a local app so I can live with the ugliness. 这是一个本地应用程序,因此我可以忍受丑陋。

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

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