htaccess

[Apache].htaccessクエリ置換

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} (^|.*&)id=100($|[^0-9])(.*)
RewriteRule ^search.*$ http://%{HTTP_HOST}%{REQUEST_URI}?%1id=200%2%3 [R=301,L]
</IfModule>

id=100をid=200に置換してリダイレクト
id以外のクエリはそのまま

[htaccess]BASIC認証とIP一部IPのみ制限

/var/www/xxxxx/public_htmlはBASIC認証又はIPが192.168.xxx.xxxならば閲覧可能
/var/www/xxxxx/public_html/secureはIPが192.168.xxx.xxxならば閲覧可能。それ以外のIPは403

/var/www/xxxxx/public_html/.htaccess

AuthUserFile /var/www/xxxxx/public_html/.htpasswd
AuthGroupFile /dev/null
AuthName "Input ID and Password."
AuthType Basic
require valid-user
SetEnvIf Request_URI "^/secure/.*$" secure_dir
Order Deny,Allow
Deny from all
allow from env=secure_dir
Allow from 192.168.xxx.xxx
<Files ~ "^\.(htaccess|htpasswd)$">
deny from all
</Files>
Satisfy Any

/var/www/xxxxx/public_html/secure/.htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^192.168.xxx.xxx
RewriteRule ^(.*)$ - [R=403,L]
</IfModule>