ルート ディレクトリにある .htaccess ファイルでこれを試してください。
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} id=(.+) [NC]
RewriteRule ^(product|supplier)/?$ /$1/%1? [NC,L,R=301]
.htaccess ファイルでは、ルールの URI パス テストに先頭のスラッシュ ( ^/product
) がないため、正規表現にも含めることができません。末尾?
は受信クエリを削除します。
ルール セットを Apache のメイン構成ファイルに配置する場合は、先頭のスラッシュを保持する必要があります。^/(product|supplier)/?$
アップデート
目的の URL を表示しながら、元の URL からデータを取得するには。
リクエスト:/product/?id=parameter
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^(GET|HEAD)\s/(product|supplier)/\?id=([^\s]+) [NC]
# Strip the query and redirect permanently
RewriteRule ^(product|supplier) /$1/%3? [R=301,L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} ^$
# Map internally to the original request
RewriteRule ^(product|supplier)/([^/]+)/? /$1/?id=$2 [L,NC]
別のオプションは、リクエストで「pretty」URL を直接使用することです。
/product/parameter
へのリクエスト/product/?id=parameter
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(product|supplier)/([^/]+)/? /$1/?id=$2 [L,NC]