使用.htaccess将url重定向到另一个域

使用.htaccess将url重定向到另一个域,.htaccess,.htaccess,我在.htaccess文件中有以下内容: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>

我在.htaccess文件中有以下内容:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

# END WordPress
你知道我该怎么解决这个问题吗

问候,


尼尔。

我正在使用此代码将我的htacces重定向到另一个网站

RewriteEngine On
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R=301,L]

这应该行。

我正在使用此代码将我的htacces重定向到另一个网站

RewriteEngine On
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R=301,L]

这应该行得通。

它应该符合您的规则,但必须放在与WordPress相关的规则之前(重写前始终重定向):

重新编写引擎打开
重写规则^this url$http://www.anotherdomain.com/ [NC,L,R=301]
#开始WordPress
重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress

它应该适用于您的规则,但必须放在与WordPress相关的规则之前(重写前始终重定向):

重新编写引擎打开
重写规则^this url$http://www.anotherdomain.com/ [NC,L,R=301]
#开始WordPress
重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress
RewriteEngine On
RewriteRule ^this-url$ http://www.anotherdomain.com/ [NC,L,R=301]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress