RegExr ( http://regexr.com?36ms0 ) でテストすると完全に機能するこの正規表現がありますが、.htaccess に追加すると一致しません。
正規表現:
^(?!.*\.(?:(?:ht|x)ml|j(?:peg|s|pg)|p(?:hp|ng)|[rc]ss|bmp|ico|gif)$).*$
この正規表現は、「testphp」や「test.rar」などの文字列と一致する必要がありますが、「test.php」やその他の含まれる拡張機能とは一致しません。
サブドメインの .htaccess
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# handle YouTube token
RewriteCond %{QUERY_STRING} ^token=(.*)$
RewriteRule ^login/ login/%1/? [NE,R=301,L]
# add trailing slash for the looks
RewriteRule ^(([a-z0-9\-]+/)*[a-z0-9\-]+)$ $1/ [NC,R=301,L]
# html5 pushstate (history) support:
# we do want to give error pages for certain file types though.
RewriteCond %{REQUEST_FILENAME} ^(?!.*?\.((ht|x)ml|j(peg|s|pg)|p(hp|ng)|[rc]ss|bmp|ico|gif)$).*?$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteRule (.*) / [L]
</ifModule>
この .htaccess ファイルの目的は、.php、.html、.css、jpg などで終わるファイル、および存在するファイルまたはディレクトリを除いて、すべてのリクエストをインデックスにリダイレクトすることです。をhttp://mysite.com/test/
参照すると、インデックスにリダイレクトされます。を参照するhttp://mysite.com/test.php
と、ファイルが表示されるか、存在しない場合は 404 が表示されます。参照するhttp://mysite.com/test.rar
と、ファイルがダウンロードされるか、存在しない場合はインデックスにリダイレクトされます。
サーバー ルートに別の .htaccess があります。
SetEnv PHPRC /home/ttrcusto/public_html/cgi-bin/php.ini
<Files ~ "\.(ini)$">
order allow,deny
deny from all
</Files>
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
Redirect /unsubscribe http://ttrcustoms.us/#account=edit
Redirect /cydia http://repo.ttrcustoms.us
Redirect /Cydia http://repo.ttrcustoms.us
Redirect /repo http://repo.ttrcustoms.us
Redirect /tools http://tools.ttrcustoms.us
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^repo/deb/(.*)\.deb$ /download.php?package=$1.deb [L,QSA]