htaccess-他のファイルへのアクセスを許可する方法[重複]

Apr 01 2020

現在、私は次のhtaccessファイルを持っています:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /v2/index.php?pg=$1 [L]
</IfModule>

何が機能していますか?

http://site/v2/test ->に行きます http://site/v2/index.php?pg=test

何が機能していないのですか?

cssまたはzipファイルをロードしたい場合http://site/v2/_downloads/download.zipは、次の場所に移動します。http://site/v2/index.php?pg=_downloads/download.zip

しかし、私は実際のページに行きたいですcssについても同じです何らかの理由でそれがロードされます:http://site/v2/index.php?pg=_css/style.css代わりにhttp://site/v2/_css/style.css

私は何を間違えましたか?ただそれを見ることができないようです。

回答

1 ErwinDubois Apr 01 2020 at 13:24

これはトリックをするようでした

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|\.bat|\.zip|\.rar|robots\.txt)$ [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /v2/index.php?pg=$1 [L] #RewriteRule ^(.*)/$ v2/index.php?pg=$1 [L]
</IfModule>