【问题标题】:Setting .htaccess to reach not the file to directory将 .htaccess 设置为不将文件访问到目录
【发布时间】:2015-06-02 17:12:51
【问题描述】:

我有一些关于 htaccess 文件的问题。我为我的网站创建了一个移动版本。我的主要网站是 wordpress,我为它的移动版本创建了一个响应式 html 网站,但我在通过手机查看 html 网站时遇到了一些问题。所以我需要学习两件事。

假设我的移动网站位于http://www.example.com/mobile/index.html

1) 我如何编辑 .htaccess 文件以使用地址 http://www.example.com/mobile 没有 index.html 的东西到达网站。

2) 当我用一些模拟器尝试我的网站时,它看起来很完美,但是当我从手机打开 example.com/mobile/index.html 时,它只显示纯 html 没有 css/js。为什么会这样?

提前致谢。

希望我足够清楚。

【问题讨论】:

  • lkyardimegitimiizmir.com/mobile/index.html 是手机版。

标签: html css wordpress .htaccess redirect


【解决方案1】:

你能提供链接吗?如果我理解正确:

1) 在你的 .htaccess 文件中试试这个

RewriteEngine On
# Check for mime types commonly accepted by mobile devices
RewriteCond %{HTTP_ACCEPT} "text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml" [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^ http://www.example.com/mobile%{REQUEST_URI} [R,L]

2) 指向您的 CSS 和 JS 文件的链接可能不正确 - 这就是您可能只看到原始 HTML 的原因。

【讨论】:

  • 那么添加我在#1 中建议的编辑是否适用于重定向?对于第 2 项,我的页面似乎加载正常。
  • 其实我不是在寻找 javascript 重定向。我需要的是使用 .htaccess 文件。
  • 更新答案 - 试试看。
猜你喜欢
  • 1970-01-01
  • 2014-10-04
  • 1970-01-01
  • 1970-01-01
  • 2014-10-24
  • 1970-01-01
  • 2012-03-13
  • 2013-05-06
  • 1970-01-01
相关资源
最近更新 更多