.htaccess重写URL而不是重定向

时间:2013-06-14 16:26:17

标签: .htaccess mod-rewrite url-rewriting

是否可以在没有重定向的情况下重写?

# redirect for the blog link
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^topgearsblog/?$ http://aerogearblog.wordpress.com/ [NC,L]

我试过它:

# redirect for the blog link
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^topgearsblog/?$ http://myblog.wordpress.com/ [L,QSA,NC]

它仍然会重定向而不是重写。

1 个答案:

答案 0 :(得分:1)

只有在Apache配置中启用mod_proxy时才有可能。启用后,您可以执行以下操作:

# redirect for the blog link
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^topgearsblog/?$ http://aerogearblog.wordpress.com/ [NC,L,P]