【发布时间】:2017-07-18 14:26:22
【问题描述】:
因此,我们最近获得了一个客户网站,该网站正在为我们的客户定制开发,它们基本上具有不友好的 URL “article.php?id=1”。我试图让他们对 SEO 友好,而在创建新 URL 时,我无法让他们的旧 URL 自动重定向到我刚刚创建的内容。
我尝试了以下方法,但没有成功:
RewriteEngine On
RewriteBase /
RewriteRule ^articulo.php?id=1$ "xerox-phaser-3020bi" [NC,R=301,L]
RewriteRule ^xerox-phaser-3260dni$ /articulo.php?id=2 [R=301,L]
RewriteRule ^xerox-phaser-33dn$ articulo.php?id=3 [L]
如您所见,我正在为每个产品(仅大约 38 个)手动创建 URL,并且由于该应用程序不打印 category.php?name=nameofcategory&article.php?id=1 我认为这是最好的方法友好的 URL。
我想要的是,当有人在我们的网站上点击 /article.php?id=1 产品时,他们会被带到友好的 URL,例如:/xerox-phaser-3260dni
谢谢!
编辑:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^id=1$
RewriteRule ^articulo\.php$ /xerox-phaser-3260dni/? [R=301,L]
此代码在访问友好 URL 时重定向但不显示页面。
【问题讨论】:
标签: php apache .htaccess mod-rewrite