2016-04-22 12 views
2

私は古いKayakoヘルプデスクのURLに301のリダイレクトを設定しようとしています。古いURLは次のとおりです。 URLのexample.com/rest_of_urlきれいであり、私が301にしようとしているので、書き換え.htaccessでの疑問符の一致

私が設定した

example.com/index.php?/rest_of_url

は、すべての古いURLの新しいにリダイレクトされます。私は以下を試しましたが、動作するようには見えません。

RewriteRule ^index.php?/(.*)?$ /$1 [R=301,L] 

RewriteRule ^index.php\?/(.*)?$ /$1 [R=301,L] 

RewriteRule ^index.(.*)/(.*)?$ /$2 [R=301,L] 

私はそれを理解できません。

EDIT:疑問符がするRewriteRuleのURLではありません後

ここでは、全体の.htaccessファイル

<IfModule mod_rewrite.c> 
RewriteEngine On 

RewriteCond %{HTTPS} off 
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

RewriteCond %{QUERY_STRING} ^/(.*)$ 
RewriteRule ^index\.php$ /%1? [R=302,L] 

RewriteCond $1 !^(admin|api|console|favicon\.ico|robots\.txt|sitemap\.xml|index\.php|tiny_mce_gzip\.php|cron|onsite|staff|rss|setup|visitor|winapp|wallboard|__swift) [NC] 
RewriteCond $1 !\.(jpg|jpeg|png|gif|js|css|htm|html)$ [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L] 

RewriteCond $1 !^(favicon\.ico|robots\.txt|sitemap\.xml|index\.php|tiny_mce_gzip\.php|__swift) [NC] 
RewriteCond $1 !\.(jpg|jpeg|png|gif|js|css|htm|html)$ [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([a-zA-Z0-9]*)/(.*)$ $1/index.php?/$2 [L] 
</IfModule> 

答えて

2

一部です。あなたは%{QUERY_STRING}を使用する必要が

RewriteCond %{QUERY_STRING} ^/(.*)$ 
RewriteRule ^index\.php$ /%1? [R=301,L] 

%1は最後RewriteCondで最初(.*)です。あなたのケースでは

は、ループせずに、使用します。このため

RewriteCond %{THE_REQUEST} \s/+index\.php\?([^\s&]+) [NC] 
RewriteRule^/%1? [R=302,L,NE] 
+0

感謝を。しかし、正しく動作しているようには見えません。「example.com/rest_of_url?rest_of_url'」にリダイレクトされているようです。 – Wasim

+0

はい、申し訳ありません、今度は '%1の後に'? 'と表示されます。 – Croises

+0

ありがとうございました。問題は、無限のリダイレクトループを実行することだけです。なぜこのことが分かりませんか?私は投稿全体を '.htaccess'で更新しました。ヘルプをよろしくお願いいたします。 – Wasim