2017-06-30 6 views
0

サイトのルートにある "content"フォルダに、自分のウェブサイトのコンテンツをすべて(ホームページの外に)置いています。これはApache 2.4.25です。AliasMatch "content"フォルダのホームページを除くすべて

http://www.example.comDirectoryIndexindex.html)のサービスをC:/DocumentRoot/にします。次のことは問題ありません。

<Directory "C:/DocumentRoot/website"> 
    Options None 
    AllowOverride None 
    Require all granted 
</Directory> 

私はその後C:/DocumentRoot/content/anything1/anything2DirectoryIndexを提供http://www.example.com/anything1/anything2持っていると思います。以下を追加した後、が機能しますが、http://www.example.comにアクセスするとForbiddenエラーが発生します。

AliasMatch "^/(.+)$" "C:/DocumentRoot/website/content/$1" 
<Directory "C:/DocumentRoot/website/content/"> 
    Require all granted 
</Directory> 

何が起こっているか、より良い/働いている選択肢がありますか?

答えて

0

AliasMatchに変更ので、DirectoryIndexindex.html)が期待通りに動作することを可能に無視します。

AliasMatch "^/(?!index.html)(.+)$" "C:/DocumentRoot/website/content/$1" 

(?!index.html)暗黙のindex.htmlが一致しないことを保証します。 (.+)は他のものを取り出し、contentフォルダから取り出します。

0

この場合、mod_rewriteは読みやすく、後でAliasMatch内の負のアサーション正規表現を拡張します。

RewriteEngine ON 
RewriteCond %{REQUEST_URI} !^/content 
RewriteRule ^/(.+) "C:/DocumentRoot/website/content/$1" 
+0

これで、 'http:// www.example.com/help'は' C:/ DocumentRoot/website/content/help'で内容をプルアップするべきではありませんか?私はあなたが 'AliasMatch'を最初に削除した' Directory'セクションの 'Require everything'の後に答えを出しました。 – user3071284

関連する問題