.htaccess 将所有内容重定向到索引(使用htaccess,且不会弄乱图像)

.htaccess 将所有内容重定向到索引(使用htaccess,且不会弄乱图像),.htaccess,.htaccess,如何将所有内容重定向到索引页面(如www.domain.com/anywhere),而不破坏该页面上的css、img和js加载 这样行吗 RewriteEngine On RewriteCond %{HTTPS} off RewriteCond %{REQUEST_URI} !^/index.html RewriteCond $1 !^(img|css|js|font) RewriteRule ^(.*)$ /index.html [L,R=301] 我倾向于使用: RewriteEngine

如何将所有内容重定向到索引页面(如www.domain.com/anywhere),而不破坏该页面上的css、img和js加载

这样行吗

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/index.html
RewriteCond $1 !^(img|css|js|font)
RewriteRule ^(.*)$ /index.html [L,R=301]
我倾向于使用:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [QSA,L]
其中,将匹配任何常规文件调用(使用
进行否定)。因此,您可以正常调用它们,其他任何内容(包括404)都会发送到索引。

我倾向于使用:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [QSA,L]

其中,将匹配任何常规文件调用(使用
进行否定)。所以你可以正常调用它们,其他任何东西(包括404)都会被发送到索引。

@niksos:很高兴知道它成功了,最好使用
RewriteCond%{REQUEST_FILENAME}-d
aswell@niksos:很高兴知道它成功了,最好使用
RewriteCond%{REQUEST\u FILENAME}-d