.htaccess - Htaccess RedirectMatch proper use -
.htaccess - Htaccess RedirectMatch proper use -
i have .htaccess file setup following. it's simple concept requests forwarded cgi-bin/controller.rb except requests in /images, /css, /javascripts, or /cgi-bin
i want root redirected /index/show that's part erroring. keeps infinitely redirecting /index/showindex/showindex/show...
can explain why redirectmatch doesn't work?
redirectmatch permanent ^/$ /index/show errordocument 404 /404 rewriteengine on rewritecond %{request_uri} !^/images/ [nc] rewritecond %{request_uri} !^/css/ [nc] rewritecond %{request_uri} !^/javascripts/ [nc] rewritecond %{request_uri} !^/cgi-bin/ [nc] rewriterule (.*) /cgi-bin/controller.rb?%{query_string}&page=$1 [l]
avoid using redirectmatch , rewriterule @ same time. different modules , applied @ different times in request-flow. can accomplish same using rewriterule's:
rewriteengine on rewritecond %{request_uri} !^/index/show [nc] rewriterule ^$ /index/show [l] rewritecond %{request_uri} !^/index/show [nc] rewritecond %{request_uri} !^/images/ [nc] rewritecond %{request_uri} !^/css/ [nc] rewritecond %{request_uri} !^/javascripts/ [nc] rewritecond %{request_uri} !^/cgi-bin/ [nc] rewriterule (.*) /cgi-bin/controller.rb?page=$1 [l,qsa]
optionally utilize rewriterule ^$ /index/show [l,r=301]
if want redirect, instead of leaving address bar nice , clean.
also remember clear browsers cache, permanent redirect cached aggressively.
.htaccess
Comments
Post a Comment