.htaccessで動的URLを静的URLに置き換えているのですが、
URLにパラメータをつけてブラウザにアクセスすると何も表示されなくなります。
実行している.htaccess
RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*)$ index.php?p=$1&%{QUERY_STRING} [L]
パラメータがある場合は&でつなげるようにしているのですが、
下記をに書き換えて実行すると&でちゃんとリダイレクトされます。
RewriteRule (.*)$ index.php?p=$1&%{QUERY_STRING} [R=301,L]
【元のURL】http://hoge.com/test/?hello=goodbye
【書き換えのURL】http://hoge.com/?p=test/&hello=goodbye
パラメータの中にスラッシュがあるのでディレクトリとして認識されているのかなと思っているのですが、
それを回避する方法がわかりません。
全体的にはこんな感じで設定しています。
<IfModule mod_rewrite.c> RewriteEngine on RewriteBase /hubhb # index系のファイル名を削除 RewriteCond %{THE_REQUEST} ^.*/index.(html|htm|php) RewriteRule ^(.*)index.(html|htm|php)$ $1 [R=301,L] # パスの最後にスラッシュを追加 RewriteCond %{REQUEST_URI} !/$ RewriteCond %{REQUEST_URI} !.[^/.]+$ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* %{REQUEST_URI}/ [R,L] # ファイルパスの書き換え RewriteCond %{REQUEST_URI} !^/hubhb/_projects RewriteRule ^(.+?)/(.*)/(.*).(.*)$ _projects/$1/html/$2/$3.$4 [L] # 動的URLに書き換え RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*)$ index.php?p=$1&%{QUERY_STRING} [L] </IfModule>
よろしくお願い致します。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/12/20 02:05