的.htaccess和SEO友好的网址 [英] .htaccess and seo-friendly urls
问题描述
我们有电子商务网站现在承载了一系列品牌。该品牌页面进行网址如下:
We have an ecommerce site right now that carries a range of brands. The brand pages carry urls as follows:
-
HTTP://www.< DOMAIN&GT;的.com /目录/品牌/视图id = 2
http://www.<DOMAIN>.com/catalog/brand/view?id=2
我们需要利用更友好(搜索引擎友好)的网址,例如:
We need to utilize more friendly (seo-friendly) urls such as:
-
HTTP://www.< DOMAIN&GT;的.com /&LT;品牌&GT;
http://www.<DOMAIN>.com/<BRAND>
但这样它可以解决上面的#1。
but such that it would resolve #1 above.
这是在.htaccess文件所做的根源在哪里?如果是这样,什么是去对此正确的方法是什么?
Is this done in .htaccess files in the root? If so, what is the correct way to go about this?
请1是合法的地址,但我们要利用URL#2格式的链接。这不是一个301重定向的类型是什么呢?这是更多的永久除非我误会了吧什么的,不是吗?
Keep in mind URL#1 is the legitimate address, but we want to utilize the URL#2 format for linking. It's not a 301 type redirect is it? That's more "permanent" unless I misunderstood it or something, no?
非常感谢。
推荐答案
您正在寻找被称为阿帕奇的功能的mod_rewrite
。你应该能够为帮助在这里谷歌和找到好的资源。
The apache feature you are looking for is called mod_rewrite
. You should be able to google and find good resources for help here.
其基本思路是你指定一个普通的前pression匹配,然后替换模式。您可以设置它做301重定向,但默认是不重定向用户,只需进入重新编写的网址。
The basic idea is you'll specify a regular expression matching and then a replacement pattern. You can set it to do a 301 redirect, but the default is to not redirect the user, just access the re-written url.
下面是一个例子:
RewriteEngine On
RewriteRule (.*) index.php
该重写规则说,重写任何匹配的URL(。*)到的index.php。这是不适合大多数文件尤其有用。我敢肯定,你将有大量的例子,因为这是一个常见的问题。
The RewriteRule says to rewrite any matching url(.*) to index.php. This is not particularly useful for most files. I'm sure you'll have plenty of examples as this is a common problem.
这篇关于的.htaccess和SEO友好的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!