【问题标题】:How to create a formatless webpage? [duplicate]如何创建无格式网页? [复制]
【发布时间】:2014-01-29 18:28:57
【问题描述】:

我看到很多网站有很多网页(除了主页)没有像http://www.apple.com/ios/这样的格式

它没有像http://www.apple.com/ios.html 这样的格式。

这个页面也是https://stackoverflow.com/questions/ask 它没有扩展名!!!

我如何创建它??

我有我的网站,我希望 mysite/login.aspx 在其中显示为 mysite/login 还有 mysite/welcome.html 作为 mysite/welcome

有人可以帮帮我吗?提前致谢!!

【问题讨论】:

  • 如果你谷歌这个你会找到你的答案。
  • 查看 htaccess 和 mod 重写
  • 尝试搜索:URL重写
  • 嗯,从技术上讲,ios 链接确实 有一个.html 扩展名,只是不是您访问它的方式。见apple.com/ios/index.html。大多数服务器在访问目录(例如,/ios/)时会提供index.html
  • @KennyThompson - 这有点误导,我帮助维护了许多网站,它们都不是基于 MVC 框架构建的,它们都使用.htaccess 进行 URL 重写

标签: html url url-rewriting format


【解决方案1】:

通常在 Apache 的 .htaccess 文件中完成。

类似这样的:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /$1 [L,R=301]

啊拉this very similar question

【讨论】:

    【解决方案2】:

    把它放在你的 .htaccess 文件中。不要自己制作,而是从 FTP 服务器下载当前文件,对其进行更改,然后上传并覆盖旧文件。

    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^securemyhome\.com
    RewriteRule ^(.*)$ http://www.securemyhome.com/$1 [R=permanent,L]
    
     # 3 ---- Make pages render without their extension in the url
     Options +MultiViews
    

    【讨论】:

      【解决方案3】:

      如果您将文件命名为 index.html(或 index.php 等)并将其上传到 mydomain.com/test/index.html,它将在 mydomain.com/test/ 上可用

      除此之外,通过 htaccess 文件使用 url 重写。 这是a good tutorial 让您入门。

      【讨论】:

        【解决方案4】:

        对于 IIS 网络服务器,

        将“Url Rewrite”模块安装到 IIS,“添加规则”并按照向导进行操作。

        download Url Rewrite

        About Url Rewrite

        【讨论】:

          猜你喜欢
          • 2021-03-06
          • 2012-01-18
          相关资源
          最近更新 更多