在我的.htaccess文件中,DirectoryIndex设置为/page/main/home.html
因此,当我转到www.thisexample.com时,浏览器地址栏在实际加载www.thisexample.com/page/main/home.html时显示www.thisexample.com。这一切都很好,但现在谈的是问题:
从.html链接到的任何home.html页面都找不到。换句话说,当我单击info链接(主页上)时,它会查找www.thisexample.com/info.html (不存在),而不是在浏览器地址栏中显示www.thisexample.com/info.html,但实际上加载www.thisexample.com/page/main/info.html (这里的最终目标)。
它可能有助于添加home.html没有问题,找到它的css样式表通过一个相对的路径,只是找不到链接。
发布于 2013-10-18 17:30:00
DirectoryIndex应该是默认文件的名称,名称与index.html或ex的index.php类似:
DirectoryIndex index.html如果您想从.html加载所有/page/main文件,那么可以使用以下重写规则:
DirectoryIndex home.html
RewriteEngine On
RewriteCond %{REQUEST_URI} !\.(?:jpe?g|gif|bmp|png|tiff|css|js)$ [NC]
RewriteRule !^page/main/ page/main%{REQUEST_URI} [L,NC]还可以在css、js、图像文件中使用绝对路径,而不是使用相对路径。这意味着您必须确保这些文件的路径以http://或斜杠/开头。
https://stackoverflow.com/questions/19455523
复制相似问题