重定向PHP页面来使用301的.htaccess另一个PHP页面 [英] Redirect php page to another php page using 301 .htaccess

查看:246
本文介绍了重定向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]

这篇关于重定向PHP页面来使用301的.htaccess另一个PHP页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆