我有一些关于 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。为什么会这样?
提前致谢。
希望我已经足够清楚了。
最佳答案
你能提供链接吗?如果我理解正确的话:
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 的原因。
关于html - 将 .htaccess 设置为不将文件到达目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29333483/