重定向PHP页面来使用301的.htaccess另一个PHP页面

问题描述:

我有一个动态的页面,我需要重定向到另一个动态页面在.htaccess。

I have a dynamic page that I need to redirect to another dynamic page in .htaccess.

我已经尝试了不同的语法重定向,但似乎没有任何工作:

I have tried different syntax for the redirect but nothing seems to work:

RewriteEngine on 
RewriteRule /index.php?p=page&page_id=store$ http://www.website.com/index.php [R=301]

RewriteEngine on 
RewriteCond %{QUERY_STRING} ^p=page&page_id=store$
RewriteRule ^/index.php$ http://www.website.com/index.php? [L,R=301]

编辑:我有,我已经转移到新的地址,购物车一个老PHP页面。因此,为了preserve搜索引擎页面排名,我想老页面重定向到新的地址。我希望观众谁仍然参观www.website.com/index.php?p=page&page_id=store被重定向到website.com/index.php~~V

I have an old php page in the shopping cart that I have transferred to the new address. So in order to preserve search engine page ranking I want to redirect old page to the new address. I want visitors who still visit www.website.com/index.php?p=page&page_id=store to be redirected to website.com/index.php

在此先感谢!

的URI被送入改写里面总是有斜线剥离的htaccess文件的规则。因此,而不是的index.php 中,你有的index.php ,因为htaccess的文件基本上是每个目录的情况下, ,类似于<目录> 指令。所以,你想要的第二个选项,但没有斜线:

URI's that are fed to rewrite rules inside htaccess files always have the leading slash stripped off. So instead of /index.php, you have index.php, since htaccess files are essentially a per-directory case, similar to the <Directory> directive. So you want the second option but without the leading slash:

RewriteEngine on 
RewriteCond %{QUERY_STRING} ^p=page&page_id=store$
# no slash --v
RewriteRule ^index.php$ http://www.website.com/index.php? [L,R=301]