使用htaccess重定向Wordpress URL

时间:2014-07-03 17:18:01

标签: wordpress .htaccess mod-rewrite rewrite

我尝试使用以下代码将某个网址(实际上我有几百个)重定向到另一个网址,但它无法正常工作。 htaccess在我的wordpress根目录中,wp-content文件等。我做错了什么?

# 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

Options +FollowSymLinks
RewriteEngine On

Redirect http://lifeandhealth.org/qr/049ow34gh9klhg3uqrf2   http://lifeandhealth.org/?p=58

2 个答案:

答案 0 :(得分:1)

  1. 通常,您将重定向行置于WordPress上方 htaccess调用(#BEGIN WordPress)。
  2. 如果这不起作用,我不确定是否会这样,但要尽量明确 尽可能。

    Redirect 301 /qr/049ow34gh9klhg3uqrf2 http://lifeandhealth.org/?p=58

    如果重定向是临时的,则将301更改为302.

  3. 这不是WordPress特有的功能,因此查看this是更高级重定向的良好资源。

    如果这不起作用,请在评论中告诉我,我会尝试使用其他(尝试过的)解决方案进行更新:)

    要记住的其他一些事项

    1. 如果这不起作用,请尝试使用&#34; /&#34;重定向整个目录。在URL的末尾(只有在你好的时候才这样做,记住它有不同的功能)
    2. 确保.htaccess文件顶部没有空行
    3. (更多的是&#34; PS:&#34;事情)这不是解决方案,也不是大量重定向数量的最佳选择,但this WordPress plugin非常棒。

答案 1 :(得分:0)

两个调整:

RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^() index.php [L]
  • 删除RewriteBase
  • 移除/
  • 前面的index