2017-05-11 15 views
0

Windowsサーバでweb.configでこれを行うことができましたが、.htaccessと同等のものはわかりません。基本的にindex.htmlを削除するだけの場合... URLは、ルートまたはサブディレクトリになります。ディレクトリインデックススクリプトを.htaccessを使用してディレクトリに移動(リダイレクト)

foo.com/index.html >>なるfoo.com/

foo.com/subdir/index.html >>なるfoo.com/subdir/

更新日:私が働いている.htaccessファイルはこれで動作します。

DirectoryIndex index.php 

<Files .htaccess> 
deny from all 
</Files> 

Options All -Indexes 

ServerSignature Off 

Options +FollowSymLinks 
RewriteEngine On 

RewriteBase/

redirectMatch 301 /donation/? /donate/ 
redirectMatch 301 /giftcard(.*) /gift-card/ 

RewriteRule ^specials/([0-9]+)/ /specials/index.php\?id=$1 [NC,L] 

答えて

0

あなたが任意のURLから/index.htmlを削除するにはApacheの設定またはサイトのルートの.htaccessにこのルールを使用することができます。

DirectoryIndex index.html 
RewriteEngine On 

RewriteCond %{THE_REQUEST} /index\.html [NC] 
RewriteCond %{REQUEST_URI} ^(.*/)index\.html$ [NC] 
RewriteRule^%1 [L,R=301,NE] 
+0

は、.htaccessファイル内で作業していないようです。私はそのファイルで作業している他の多くのルールを持っていますが、これはまだトリックではありません。何か案は? – Dan

+0

btw私はこのルールを私のApacheでテストしたところ、うまくいきました。 – anubhava

+0

元の投稿を更新して、作業用の.htaccessファイルを追加しました。 私はそれをすべて落としてコードに貼り付けましたが、それでも機能しませんでした。 – Dan

関連する問題