如何使用.htaccess将静态重定向到动态URL(在Wordpress网站上)

I've taken over a former site/domain, and set up a new site using Wordpress. The WP installation rewrites URL's to static ones, as you'd expect it to.

At the same time I want to preserve the former pages, as they have incoming links. I'm not interested in 301'ing them to "new" pages.

The old URL structure is /index.php?id=123, which I suspect is causing the problem with the WP .htaccess file. For reference, this is what it looks like:

# 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

I've tried adding the following:

RewriteRule ^([0-9]+).html index.php?id=$1 [R,L]

Doesn't work. Just redirects to site.com/?id=123 and shows the front page.

I should add that I plan on just adding these new pages as regular static HTML files in the format of 123.html, 321.html etc.

How do I use .htaccess to make this work together with the WP installation and what WP puts into the .htaccess file?

To clarify:

I want to have my 123.html static HTML page be index.php?id=123. When you access index.php?id=123 it should bring up 123.html, but show index.php?id=123 in the address bar. If you access 123.html it should 301 to index.php?id=123.

查看全部
duangan6797
duangan6797
2015/04/30 14:54
  • redirect
  • wordpress
  • php
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复