简体   繁体   English

我想使用htaccess或php将旧网址重定向到新的重写网址

[英]I want to redirect old url to new rewrite url using htaccess or php

I have a problem since i using rewrite url.. 我有一个问题,因为我使用的是重写网址。

MY OLD URL: Website.com/index.php?act=appdetail&appid=oWV 我原来的网址: Website.com/index.php?act=appdetail&appid=oWV

New Rewrite URL http://website.com/angry_birds_rio-appdetail-oWVi.html 新的重写URL http://website.com/angry_birds_rio-appdetail-oWVi.html

But all my old url are indexed in google and if any one come to my website its display the old URL and google also INDEXED the NEW URL. 但是我所有的旧网址都在google中建立了索引,如果有任何人进入我的网站,它会显示旧网址,而google也会显示新网址。 its make duplicate page on website problem. 它使网站问题上的重复页面。

Let me know the solution 让我知道解决方法

My rewrite URL htaccess 我的重写URL htaccess

RewriteEngine On RewriteEngine开

RewriteRule ^([^-] )-([^-] )-([^-] )-([^-] )-([^-]*).html$ index.php?appanme=$1&act=$2&appid=$3&page=$4&cat=$5 [L] RewriteRule ^([^-] )-([^-] )-([^-] )-([^-] )-([^-] *)。html $ index.php?appanme = $ 1&act = $ 2 &appid = $ 3&page = $ 4&cat = $ 5 [L]

RewriteRule ^([^-] )-([^-] )-([^-] )-([^-] )-([^-] )-([^-] ).html$ index.php?appanme=$1&act=$2&appid=$3&page=$4&cat=$5&sString=$5 [L] RewriteRule ^([[^-] )-([^-] )-([^-] )-([^-] )-([^-] )-([^-] ).html $ index.php? appanme = $ 1&act = $ 2&appid = $ 3&page = $ 4&cat = $ 5&sString = $ 5 [L]

RewriteRule ^([^-] )-([^-] )-([^-]*).html$ index.php?appanme=$1&act=$2&appid=$3[L] RewriteRule ^([^-] )-([^-] )-([^-] *)。html $ index.php?appanme = $ 1&act = $ 2&appid = $ 3 [L]

Here is your .htaccess file: 这是您的.htaccess文件:

RewriteEngine on
RewriteRule ^/index.php?act=appdetail&appid=oWV$ http://website.com/angry_birds_rio-appdetail-oWVi.html [R=301,L] 

You'll need to inform to web crawlers about the redirection, you cando it with a 301 code. 您需要将有关重定向的信息告知网络爬虫,您可以使用301代码来实现。

Appears the rule are .htaccess based; 出现规则是基于.htaccess的; you need an additional set of rules to permanently redirect (301) BROWSER/CRAWLER requests for the index.php pages, if a set of CGI arguments are present, to the appropriate alias, this will tidy up Google in a few weeks. 您需要另外一套规则来永久重定向(301)BROWSER / CRAWLER对index.php页面的请求(如果存在一组CGI参数)到适当的别名,这将在几周后使Google收拾。 Then your rules above eg 然后你上面的规则,例如

RewriteEngine On
RewriteBase /

#Permanently redirect BROWSER requests for the index.php?xxx to the appropriate page alias:
RewriteCond %{THE_REQUEST}      /index.php     [NC]
RewriteCond %{QUERY_STRING}     ^appanme=([^&]+)&act=([^&]+)&appid=([^&]+)&page=([^&]+)&cat=([^&]+)&sString=([^&]+)  [NC]
RewriteRule ^.*                 http://%{HTTP_HOST}/%1-%2-%3-%4-%5-%6.html [R=301,L]

RewriteCond %{THE_REQUEST}      /index.php     [NC]
RewriteCond %{QUERY_STRING}     ^appanme=([^&]+)&act=([^&]+)&appid=([^&]+)&page=([^&]+)&cat=([^&]+)  [NC]
RewriteRule ^.*                 http://%{HTTP_HOST}/%1-%2-%3-%4-%5.html   [R=301,L]

RewriteCond %{THE_REQUEST}      /index.php     [NC]
RewriteCond %{QUERY_STRING}     ^appanme=([^&]+)&act=([^&]+)&appid=([^&]+)  [NC]
RewriteRule ^.*                 http://%{HTTP_HOST}/%1-%2-%3.html   [R=301,L]

# Followed by: YOUR RULES FROM ABOVE

Note : 注意事项

1) There appears to be a typo in YOUR second rule: sString=$6 NOT sString=$5 1)您的第二条规则似乎有错字:sString = $ 6 NOT sString = $ 5

2) The Apache mod_rewrite documentation is worth a read if your unclear as to what the above rules do, or if you want something a little more abstract consider the following post . 2)如果您不清楚上述规则的用途,或者如果您想要更抽象的内容,请阅读以下文章 ,这是值得阅读的Apache mod_rewrite文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM