0

すべての不明なリクエストを index.html にリダイレクトしようとしています。たとえば、誰かが次のように入力した場合:

http://IP_Address/blah_blah _blah 

次に、index.html にリダイレクトする必要があります。以下は私が試したコードです:

私は自分のルートディレクトリを下に持っています/var/www/some_dir/index.html

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.html$
RewriteRule . index.html [R=302,L]

このコードを試したところ、リダイレクトされましたhttp://Ip_address/var/www/accesspage/index.html

私が欲しいhttp://Ip_address/index.html

しかし、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>
4

1 に答える 1

1

.htaccess を使用してカスタム 404 ページを作成し、そのページで header() を使用してユーザーをリダイレクトします。(php を使用したくない場合は、javascript でリダイレクトすることもできます)

于 2013-03-01T06:00:35.467 に答える