【问题标题】:Hide .html in url在 url 中隐藏 .html
【发布时间】:2013-02-18 21:39:26
【问题描述】:

我想从 url 中隐藏 .html,例如 www.site.com/videos.html 到 www.site.com/videos。我在这里寻找类似的问题,但没有结果。

这是我的 .htaccess 文件:

RewriteEngine On
RewriteRule ^index.html$ index.php
RewriteRule ^browse-(.*)-videos.html$ category.php?cat=$1
RewriteRule ^browse-(.*)-videos-([0-9]+)-(.*).html$ category.php?cat=$1&page=$2&sortby=$3

RewriteRule ^register.html$ register.php
RewriteRule ^contact_us.html$ contact_us.php
RewriteRule ^edit_profile.html$ edit_profile.php
RewriteRule ^suggest.html$ suggest.php
RewriteRule ^upload.html$ upload.php
RewriteRule ^upload_avatar.html$ upload_avatar.php
RewriteRule ^suggest.html$ suggest.php

RewriteRule ^favorites.html(.*)$ favorites.php$1
RewriteRule ^login.html(.*)$ login.php$1
RewriteRule ^newvideos(.*)$ newvideos.php$1
RewriteRule ^topvideos.html(.*)$ topvideos.php$1
RewriteRule ^profile.html(.*)$ profile.php$1
RewriteRule ^favorites.html(.*)$ favorites.php$1
RewriteRule ^playlist/(.*)$ myfavorites.php?u=$1
RewriteRule ^memberlist.html(.*)$ memberlist.php$1

RewriteRule ^articles/read-(.*)_([0-9]+).html$ article_read.php?a=$2
RewriteRule ^articles/index-([0-9]+).html$ article.php?page=$1
RewriteRule ^articles/browse-(.*)-([0-9]+).html$ article.php?c=$1&page=$2
RewriteRule ^articles/tag/([^/]+)/page-([0-9]+)(/)?$ article.php?tag=$1&page=$2
RewriteRule ^articles/tag/([^/]+)(/)?$ article.php?tag=$1&page=1
RewriteRule ^articles/popular-([0-9]+).html$ article.php?show=popular&page=$1
RewriteRule ^articles(\/|.html)?$ article.php
RewriteRule ^article(\/|.html)?$ article.php
RewriteRule ^pages/(.*)\.html$ page.php?name=$1

RewriteRule ^tags/([^/]+)/$ tag.php?t=$1&page=1
RewriteRule ^tags/([^/]+)/page-([0-9]+)(/)?$ tag.php?t=$1&page=$2
RewriteRule ^([^/]*)-video_(.*).html$ watch.php?vid=$2
RewriteRule ^fpembed-(.*).swf$ fpembed.php?vid=$1
RewriteRule ^rss.xml$ rss.php [L]</code></pre>

【问题讨论】:

    标签: html .htaccess url hide


    【解决方案1】:

    试试这个:
    RewriteRule ^([^.]+)$ $1.html [NC,L]

    【讨论】:

      【解决方案2】:

      如果您只想将客户端从videos.html 重定向到videos

      RewriteRule ^/?videos.html$ /videos
      

      这要求 /videos 是一个有效的 URL。

      【讨论】:

      • 我将 ^topvideos.html(.*)$ topvideos.php$1 更改为 ^topvideos$ topvideos.php$1 并工作,但将我重定向到 /topvideos.html 而不是 /topvideos
      猜你喜欢
      • 2011-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-03
      • 2012-01-06
      相关资源
      最近更新 更多