[英]How to redirect ServerAlias on Apache2 or mod_rewrite?
我在Apache中有一個虛擬主機
<VirtualHost *:8080>
ServerName example.eu
ServerAlias www.example.eu
ServerAlias www.somethingElseThanExample.net
DocumentRoot "/something"
<Directory "something">
Options ExecCGI FollowSymLinks
AllowOverride all
Allow from all
Order allow,deny
</Directory>
</VirtualHost>
我想重定向
www.somethingElseThanExample.net
到www.somethingElseThanExample.net/foo/
這必須適用於主頁和內部頁面,以便
www.somethingElseThanExample.net/bar/
到www.somethingElseThanExample.net/foo/bar/
是否可以通過htaccess使用Apache mod_rewrite
做到這一點? 在每種情況下我該怎么做?
如果我只需要主頁有此結果怎么辦?
由於您似乎可以訪問VirtualHost,因此可以將以下內容添加到<Directory>
部分:
RewriteCond %{HTTP_HOST} =www.somethingElseThanExample.net [NC]
RewriteCond %{REQUEST_URI} !^/foo/
RewriteRule (.*) /foo/$1 [R=302,L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.