【问题标题】:Redirect to a new domain & change url structure htaccess重定向到新域并更改 url 结构 htaccess
【发布时间】:2012-08-10 21:59:18
【问题描述】:

我正在尝试将 wordpress 博客从旧域重定向到新域并更改新域上 url 的结构。

所以我希望 www.domainA.com 重定向test.domainB.com/folder/www.domainA.com/2001/12/some-post 重定向到 test.domainB.com/folder/some-post em>

这是我目前在我的 htaccess 文件中的内容。我已经成功实现了我的第二个目标,但是如果您访问 www.domainA.com,它不会重定向到 test.domainB.com /folder/ 除主页外,所有其他页面均正确重定向。

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domainA\.com$ [NC]
RewriteRule ^([0-9]+)/([0-9]+)/(.*)$ http://test.domainB.com/folder/$3 [R=301,NC,L]

RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

我确定我错过了一些基本的东西,但我似乎无法弄清楚:(

【问题讨论】:

  • 如果你想使用假域名,examples可以。

标签: wordpress .htaccess redirect


【解决方案1】:

试试这个代码:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?domainA\.com$ [NC]
RewriteRule ^/?\d+/\d+/(.*)$ http://test.domainB.com/folder/$1 [NC,L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?domainA\.com$ [NC]
RewriteRule ^/?$ http://test.domainB.com/folder/ [NC,L,R=301]

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /index.php [L]

【讨论】:

    猜你喜欢
    • 2016-07-20
    • 2013-01-07
    • 2012-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-12
    • 1970-01-01
    • 2012-04-27
    相关资源
    最近更新 更多