Mod rewrite 将所有请求重定向到index.html

Mod rewrite 将所有请求重定向到index.html,mod-rewrite,redirect,apache2,Mod Rewrite,Redirect,Apache2,我正在尝试将所有未知请求重定向到index.html。例如,如果有人进入: http://IP_Address/blah_blah _blah 然后它必须重定向到index.html。以下是我尝试过的代码: 我的根目录位于/var/www/some\u dir/index.html RewriteEngine on RewriteCond %{REQUEST_URI} !^/index.html$ RewriteRule . index.html [R=302,L] 当我尝试此代码时,它正

我正在尝试将所有未知请求重定向到index.html。例如,如果有人进入:

http://IP_Address/blah_blah _blah 
然后它必须重定向到index.html。以下是我尝试过的代码:

我的根目录位于
/var/www/some\u dir/index.html

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.html$
RewriteRule . index.html [R=302,L]
当我尝试此代码时,它正在重定向到
http://Ip_address/var/www/accesspage/index.html

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.html$
RewriteRule . index.html [R=302,L]
我想要
http://Ip_address/index.html

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.html$
RewriteRule . index.html [R=302,L]
但是我想通过index.html重定向到其他html页面

下面是我的Apache配置

DocumentRoot /var/www/access/
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www/access/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>
DocumentRoot/var/www/access/
选项如下符号链接
不允许超限
选项索引跟随符号链接多视图
允许超越所有
命令允许,拒绝
通融

只需使用.htaccess创建自定义404页面,并在该页面上使用header()重定向用户。
(如果你不想使用php,也可以使用javascript重定向)

如果我没弄错的话,你的Web服务器配置有问题。我添加了apache congi。请检查,这一切都是正确的:
RewriteRule/index.html[R=302,L]
创建一个名为404.html的页面,并在htaccess文件中写入:ErrorDocument 404/404.html。然后在404.html页面中使用javascript重定向用户