搜索引擎友好的URL(Search-Engine Friendly URLs)

   IT问题网   2018-03-07 00:00:00

问 题

我的工作在建设我的第一个搜索引擎友好的cms。我知道,也许是最大的关键有和搜索引擎优化的一个网站是有搜索引擎友好的url。因此,有这样一个链接:

http://www.mysite.com/product/details/page1

将导致更好的排名比一个像这样的:

http://www.mysite.com/index.phppageid=37

我知道,创建url喜欢第一个,我有两个选择之一:

  • 使用网络技术,在这种情况下,php,创建一个目录结构
  • 在充分利用apache的的mod_rewrite 附加有这些url传递到一个php处理器

至于php的推移,我是pretty的舒服什么。但是,我认为第一种选择将更加难以维持。

有人能告诉我如何写的.htaccess 文件,该文件将:

  • 在默默的直接搜索引擎优化的url处理器脚本
  • 不是重定向请求的url是在服务器
  • 的实际目录

难道还有比我想它的方式更好的办法?

解决方案

您可以用.htaccess的apache,在网络主要是"htdocs目录"根文件夹中创建的文件命名为"的.htaccess"旁边添加内容

  ifmodule mod_rewrite.c
rewriteengine叙述上
的rewritecond%{} request_filename!-d
的rewritecond%{} request_filename!-f
重写规则^(。*)$的index.php?url = $ 1 [qsa,l]
选项-indexes
 / ifmodule
 

在你的php文件,你可以访问$ _ get数据。

$ _ get ['url'];
 

然后你可以用数据来分析你所需要的。

标签:搜索引擎友好



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

斜杠之后将文字与.htaccess的变量(Turn text after slashes into variables with HTACCESS)

problem i need to pass 3 variables with a url but using s ...

从URL删除字符与htaccess的(Remove Characters from URL with htaccess)

problem hopefully someone can see what i'm do ...

重定向所有的HTML扩展到.PHP(redirect all .html extensions to .php)

problem i want to update all the pages on a website to us ...

需要转义#(哈希/磅)字符在.htaccess重写规则(need to escape # (hash/pound) character in .htaccess rewrite rule)

problem the question is fairly simple but i w ...

如何使用的.htaccess重写规则改变下划线以破折号(How do I use .htaccess RewriteRule to change underscores to dashes)

problem i'm working on a site, and its cms used to save n ...

请求实体太大PHP(Request Entity Too Large PHP)

problem in one of my cakephp site, i got this error. req ...

的.htaccess使用PHP $ _GET缩短网址(.htaccess shorten URL using php $_GET)

problem i need to be able to shorten my page from: mydom ...

Gzip已融为一体pression通过的.htaccess不工作(Gzip compression through .htaccess not working)

problem i have been creating a site and checking it's spe ...

重定向www.subdomain.example.com到subdomain.example.com(redirecting www.subdomain.example.com to subdomain.example.com)

problem i've had some users trying to access a site that ...

添加尾随斜线的.htaccess(Add Trailing Slash .htaccess)

problem i'm trying to get the following effec ...

禁用所有的CGI(PHP,PERL,...)使用的.htaccess目录(Disable all CGI (php, perl, …) for a directory using .htaccess)

problem i have a directory where users can upload files. ...

在某个目录设置为仅附件上的文件内容处理标头?(Set Content-Disposition header to attachment only on files in a certain directory)

problem i've got this this rule in my htaccess file to fo ...

阿帕奇升级到2.4后,内部URL重写不再工作(Internal URL rewrite no longer working after upgrading Apache to 2.4)

problem i need to internally rewrite the base url so that ...

使用codeigniter共享托管服务器上的困惑(Puzzled using codeigniter on shared hosting server)

problem this ones a new on me. i'm transferring a site i ...

通过用户代理或空的查询块(Block by useragent or empty referer)

problem a stranger bot (gbplugin) is codifying the urls o ...

的.htaccess中:RewriteEngine此处不允许(.htaccess: RewriteEngine not allowed here)

problem i uploaded the .htaccess to the server and receiv ...

htaccess的通配符子域(.htaccess Wildcard Subdomains)

problem i'm trying to implement a solution using .htacces ...

删除的.html和.PHP与htaccess的扩展(Remove .html and .php extensions with .htaccess)

problem how do i remove the file type from my ...

重定向到其他域,但保持类型化域名(Redirect to other domain but keep typed domain)

problem after looking on the internet for about an hour, ...

在PHP 5.4启用了register_globals(Enable register_globals in PHP 5.4)

problem i am working on a framework that uses register_gl ...