【发布时间】:2015-02-19 15:27:52
【问题描述】:
这个问题涉及这两个问题: Creating Ajax website with links of multiple subfolders is failing 和 SVG href ID is not found when being on a subsite/subfolder 但不需要阅读。
所以我只想知道如何使用 htaccess启用对多个子文件夹的重定向。这是我当前的 htaccess 文件:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php [L]
顺便说一句:我删除了 index.html 中的整个基本路径元标记,因为它比对我有任何用处更麻烦。
基本上网站正确显示在:
- example.net
- example.net/
- example.net/about
但它不起作用:
- example.net/about/
- example.net/about/creator
那么我该如何更改 htaccress 文件,以便最后两个 URL 也被重定向到 index.html。我的意思是我认为这里的问题不是 SVG 问题,它是一个非常简单的 htaccess 问题。
经过一番调查……
我发现重定向是正确的。只是所有的外部css、js等文件都没有正确定位。
那我该怎么用
<link rel="stylesheet" type="text/css" href="css/default.css" media="screen"/>
而不是
<link rel="stylesheet" type="text/css" href="http://localhost/css/default.css" media="screen"/>
没有基本路径元标记。如果我在代码中的任何位置更改相对绝对路径,它就可以工作...
我知道这很奇怪。但是正如您所看到的,基本路径有利有弊。以及绝对路径和相对路径。
【问题讨论】:
-
你有更多的重写规则还是只有这些?还是您系统中的任何其他 .htaccess?
标签: html apache .htaccess redirect svg