私は基本的に欲しい:
http://example.com/index.php?page=abcにリダイレクトするにはhttp://www.exmaple.com/abc
私は持っている:
RewriteCond %{QUERY_STRING} ^page=(.*)$
RewriteRule ^index.php$ %1? [R=301]
RewriteRule ^%1$ index.php?page=%1 [L]
私は基本的に欲しい:
http://example.com/index.php?page=abcにリダイレクトするにはhttp://www.exmaple.com/abc
私は持っている:
RewriteCond %{QUERY_STRING} ^page=(.*)$
RewriteRule ^index.php$ %1? [R=301]
RewriteRule ^%1$ index.php?page=%1 [L]
2 番目のルールにいくつかの構文の問題があり、1 番目のルールにロジックの問題があります。
以下が機能するはずです:
RewriteEngine On
# for external redirection from `/index.php?page=abc` to `/abc`
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php\?page=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=301,L]
# for internal redirection from `/abc` to `/index.php?page=abc`
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /index.php?page=$1 [L,QSA]