【问题标题】:URL rewriting: Rewrite index.html to /home-page search friendly textURL 重写:将 index.html 重写为 /home-page 搜索友好文本
【发布时间】:2015-07-07 13:49:57
【问题描述】:

我所有的网站页面在其相关目录下都被命名为 index.html。 例如:

www.mydomain.com 

带我去

 www.mydomain.com/index.html

然后点击 about-us 页面,URL 为

www.mydomain.com/about-us/index.html

(其中 about-us 是目录名)

如何使用 .htaccess 重写这些 URL,以便我的网站对搜索更友好?像: 当用户去 www.mydomain.com 它应该将 URL 重写为

www.mydomain.com/my-home-page

当用户去

www.mydomain.com/about-us/index.html

它应该将 URL 重写为

www.mydomain.com/about-us/About-Me-Page

【问题讨论】:

  • 为什么需要创建额外的结构?您已经拥有about-us。将其设为www.mydomain.com/about-us/About-Me-Page 是多余的,只需将文件夹重命名为 About-me-page 即可。当用户转到www.mydomain.com/about-us 时,无论如何都不应该显示索引文件名,所以它已经是 SEF,任何使用过互联网的人都知道主域通常是网站的主页
  • 我想这样做是因为我想让我的网站在 SEO 方面搜索友好。客户站点是canyonstudios.com.pk,我想将首页的URL改写为canyonstudios.com.pk/best-dentist-services,该怎么做?

标签: apache .htaccess mod-rewrite url-rewriting


【解决方案1】:
RewriteEngine On
RewriteRule ^$ /my-home-Page.html [L,NC]
RewriteRule ^about-us/index.html$ /about-us/about-me-page.html [L,NC]

【讨论】:

  • 谢谢!但如果我使用您所说的第一条规则,我必须手动将所有具有 index.html 名称的文件更改为 meaning-full-name.html 页面。有什么办法可以避免手动更改所有 index.html 文件,并且在地址栏仍然有用户友好的 URL?
猜你喜欢
  • 2023-03-11
  • 2012-09-06
  • 1970-01-01
  • 2015-07-29
  • 2016-01-27
  • 2021-07-06
  • 2011-09-25
  • 2013-10-09
  • 1970-01-01
相关资源
最近更新 更多