mod_rewrite and";“漂亮的URL”;

mod_rewrite and";“漂亮的URL”;,url,mod-rewrite,seo,Url,Mod Rewrite,Seo,我对使用mod_rewrite来创建干净、SEO友好的URL装备不足,但我真的决心学习。我找到了各种在线教程,但似乎无法真正理解这些信息,无法以我喜欢的方式进行操作 I have a home page: http://mysite.com/index.html which I would like to display as: http://mysite.com/home 同样,我有子目录: http://mysite.com/about/index.html http://mysite.

我对使用mod_rewrite来创建干净、SEO友好的URL装备不足,但我真的决心学习。我找到了各种在线教程,但似乎无法真正理解这些信息,无法以我喜欢的方式进行操作

I have a home page: http://mysite.com/index.html

which I would like to display as: http://mysite.com/home
同样,我有子目录:

http://mysite.com/about/index.html
http://mysite.com/contact/index.php
Which I would like to display as 
http://mysite.com/about
and http://mysite.com/contact
和不同产品的图库部分,每个产品都有一个独特的页面,例如:

http://mysite.com/products/happybunnies.html OR
http://mysite.com/products/sillytigers.html
That I want to display as:
http://mysite.com/products/happy-bunnies/ AND
http://mysite.com/products/silly-tigers/
最后一个对我来说是最重要的。如果有人能慷慨地解释:

  • 整个.htaccess文件的外观,包括实际编写代码之前的任何必要的开始和结束标记

  • mod_重写代码,采用“happybunnies.html”并使其成为“快乐兔子”。以及html文件中允许这种情况发生的任何必要信息。(我在URL中看到类似“name=”的内容,但我不知道该将其放在文件中的什么位置)

  • 我觉得它很简单,但我只是错过了更好的理解。非常感谢你

    RewriteEngine on
    RewriteCond %{QUERY_STRING} =m=1
    RewriteCond %{REQUEST_URI} =/index.html
    RewriteRule ^.* /home? [R=301]
    RewriteRule ^home /index.html?m=1 [QSA]
    
    试一试,看看它对你有什么好处