简体   繁体   English

PHP htaccess中的SEO友好网址

[英]SEO friendly url in PHP htaccess

I use Godaddy Apache server to build my own blog, and I did some search of SEO friendly url tutorials, and applied the following code in my web root .htaccess file to transfer links like http://www.bgmemo.com/blog.php?url=2012/08/23/4-steps-to-initialize-Apache-Derby-10-9-1-0-in-Netbeans-7-1-1.html to http://www.bgmemo.com/blog/2012/08/23/4-steps-to-initialize-Apache-Derby-10-9-1-0-in-Netbeans-7-1-1.html : 我使用Godaddy Apache服务器建立自己的博客,并进行了SEO友好的URL教程搜索,并在我的Web根.htaccess文件中应用了以下代码以传输诸如http://www.bgmemo.com/blog之类的链接。 php?url = 2012/08/23 / 4-steps-to-initialize-Apache-Derby-10-9-1-0-in-Netbeans-7-1-1.htmlhttp://www.bgmemo。 com / blog / 2012/08/23 / 4-steps-to-initialize-Apache-Derby-10-9-1-0-in-Netbeans-7-1-1.html

RewriteEngine on
RewriteRule ^([a-zA-Z0-9-/]+).html$ blog.php?url=$1
RewriteRule ^([a-zA-Z0-9-/]+).html/$ blog.php?url=$1

But it does not work. 但这行不通。 The htaccess is working and other code in it is applied. htaccess正在运行,并且应用了其中的其他代码。 Who can tell me what is wrong? 谁能告诉我哪里错了? Thanks in advance. 提前致谢。

Try this: 尝试这个:

RewriteEngine on
RewriteBase /
RewriteRule ^blog/([a-zA-Z0-9\-/\.]+)/?$ blog.php?url=$1 [L]

This is the correctly way for don´t have problems with your .htaccess 这是正确的方法,您的.htaccess不会有问题

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /
  RewriteRule ^blog/([a-zA-Z0-9\-/\.]+)/?$ blog.php?url=$1 [L]
</IfModule>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM