http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule
What is matched?
In VirtualHost context, The Pattern will initially be matched against the part of the URL after the hostname and port, and before the query string (e.g. "/app1/index.html").
In Directory and htaccess context, the Pattern will initially be matched against the filesystem path, after removing the prefix that led the server to the current RewriteRule (e.g. "app1/index.html" or "index.html" depending on where the directives are defined).
If you wish to match against the hostname, port, or query string, use a RewriteCond with the %{HTTP_HOST}, %{SERVER_PORT}, or %{QUERY_STRING} variables respectively.
・VirtualHostディレクティブの場合はURLのパスが対象となり先頭に/がつく
・Directoryディレクティブや.htaccessの場合はそのディレクトリからの相対ファイルパスが対象になり先頭に/がつかない
.htaccessなら、
RewriteRule ^/user/.*\.txt$ - [F,L]
↓
RewriteRule ^user/.*\.txt$ - [F,L]
と、いう事でしょうか?
RewriteRule ^/?user/.*\.txt$ - [F,L]
こうすれば、両方に対応できそうですかね?未検証です。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2015/08/31 03:15