【发布时间】:2012-07-26 05:17:54
【问题描述】:
我是 StackOverflow 的新手,所以我会尽我所能,尽可能地清楚。我正在重写我的 URL 以对 SEO 更友好,所以我研究了 mod_rewrite 并认为这可能是最好的方法。我正在开发一个电子商务网站(这个细节稍后会很重要)。
因此,对于像/about_us.php 这样的简单页面,重定向非常容易。
RewriteEngine on
RewriteBase /
RewriteRule ^about-us/$ /about_us.php
我想我们都同意这一点。当我尝试在过滤器页面上重写 URL 时出现问题。所以在像
这样的页面上example.com/examplefile.php?filter1=a&filterb=2&filterc=3
重定向仍然很容易。 (注意:我选择在值前写“filter1”)
RewriteRule ^/products/filter1-([-a-zA-Z0-9]+)/filter2-([-a-zA-Z0-9]+)/filter3-([-a-zA-Z0-9]+)/$ /examplefile.php?filter1=$1&filterb=$2&filterc=$3
这是我偶然发现的部分:假设过滤器的顺序可能不同
example.com/examplefile.php?filterb=2&filter1=a&filterc=3
我不会在.htaccess 中写下所有可能性,因为我有 6 个不同的过滤器,而且您可以使用 1、2、3... 到 6 个过滤器,无论是否有序,它都是.. . 很多可能性(我会让你做数学;))。
你有任何关于 mod_rewrite 的解决方案,或者有其他的解决方案吗?我正在考虑 301 重定向,但我担心的是链接将如何出现在搜索引擎中。我正在着手 SEO,但有些部分对我来说仍然是一个谜(我想这就是 Google 想要的向导! )
【问题讨论】:
标签: php .htaccess mod-rewrite redirect seo