1

我需要在 Apache 中为 mod_rewrite 创建重写规则,但我很难理解整个语法。

我有如下链接:

http://www.example.com/0001/images/image1.gif

我需要他们将其重定向到完全其他服务器,例如:

http://127.127.127.127/0001/images/image1.gif

这是可以实现的吗?

4

1 回答 1

1

通过example.com启用 mod_rewrite 和 .htaccesshttpd.conf然后将此代码放在您.htaccessDOCUMENT_ROOT目录中:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(www\.)example\.com$ [NC]
RewriteRule ^ http://127.127.127.127%{REQUEST_URI} [R=301,L]
于 2013-08-16T07:53:19.193 回答