我刚刚将一段很久以前写过的网站迁移到wordpress。
这样做会导致url结构现在使用mod-rewrite。我意识到,在我将新网站发布后,已经发送了一些电子邮件,客户可以使用旧网址从网站上兑换礼券。
我的问题是,htaccess是否有我可以做的网址重定向并保留获取信息。例如,我需要这个网址:
www.test.com/redeem.php?id=123
重定向到:
www.test.com/redeem/now/?id=123
如果没有.htaccess
的解决方案,有没有人有PHP的解决方案?
这是我的htaccess文件现在的样子:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
感谢您的帮助。
答案 0 :(得分:0)
是否会像你想要的那样
http://test.com/redeem/now/read/2
.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
答案 1 :(得分:0)
我最终做的是在头文件中编写此代码并且它可以正常工作。
<?php
if (array_shift(explode('?', $_SERVER['REQUEST_URI'])) == "/redeem.php") {
header ('Location: /gift-certificates/redeem/?id=' . $_GET["id"] );
}?>