搜索引擎友好的URL [英] Search-Engine Friendly URLs
问题描述
我的工作在建设我的第一个搜索引擎友好的CMS。我知道,也许是最大的关键有和搜索引擎优化的一个网站是有搜索引擎友好的URL。因此,有这样一个链接:
I am working on building my first search-engine friendly CMS. I know that perhaps one of the biggest keys to having and SEO site is to have search-engine friendly URLs. So having a link like this:
http://www.mysite.com/product/details/page1
将导致更好的排名比一个像这样的:
will result in much better rankings than one like this:
http://www.mysite.com/index.php?pageID=37
我知道,创建URL喜欢第一个,我有两个选择之一:
I know that to create URLs like the first one, I have one of two options:
- 使用网络技术,在这种情况下,PHP,创建一个目录结构
- 在充分利用Apache的
的mod_rewrite
附加有这些URL传递到一个PHP处理器
- use a web technology, in this case PHP, to create a directory structure
- leverage Apache's
mod_rewrite
add-on to have these URLs passed to a PHP processor
至于PHP的推移,我是pretty的舒服什么。但是,我认为第一种选择将更加难以维持。
As far as the PHP goes, I'm pretty comfortable with anything. However, I think the first option would be more difficult to maintain.
有人能告诉我如何写的.htaccess
文件,该文件将:
Could someone show me how to write an .htaccess
file, which will:
- 在默默的直接搜索引擎优化的URL处理器脚本
- 不是重定向请求的URL是在服务器 的实际目录
难道还有比我想它的方式更好的办法?
Is there a better way than the way I am trying it?
推荐答案
您可以用.htaccess的Apache,在网络主要是htdocs目录根文件夹中创建的文件命名为的.htaccess旁边添加内容
You can use .htaccess for apache, create file in your root folder of web mainly "htdocs" name it ".htaccess" add next content to it
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
Options -Indexes
</IfModule>
在你的PHP文件,你可以访问$ _ GET数据。
in your php file you can access data from $_GET
$_GET['url'];
然后你可以用数据来分析你所需要的。
Then you can use data to parse what you need.
这篇关于搜索引擎友好的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!