rub*_*o77 0 redirect apache-2.4
我只需要在 Apache 2.4 中将http://example.org/重定向到http://www.something-other.org/ 。
只是主页。没有其他的。即http://example.org/?page=blog或http://example.org/contact.html不应重定向。
我所能找到的就是将页面完全重定向到另一个网站,例如:
Redirect "/" "http://www.something-other.org/"
Run Code Online (Sandbox Code Playgroud)
这更好一点:
RewriteEngine On
RewriteRule ^/$ http:// www.something-other.org/ [L,R=301]
Run Code Online (Sandbox Code Playgroud)
它仅重定向主页,而且如果有查询字符串也会重定向。
您需要使用mod_rewrite
:
RewriteEngine On
RewriteCond "%{QUERY_STRING}" "^$"
RewriteRule "^/$" http://something-other.org/ [L,R=301,QSD]
Run Code Online (Sandbox Code Playgroud)
该QSD
标志丢弃查询字符串。
启用mod_rewrite
并重新启动apache
:
root@host:~# a2enmod rewrite
root@host:~# service apache2 restart
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9388 次 |
最近记录: |