php - Htaccess rewriting multiple variables -
i dumb when comes .htaccess, through numerous attempts learn basics. here:
this current .htaccess:
rewriteengine on rewriterule ^$ /splash [l,r=301] rewritecond %{http_host} ^domain\.com$ [nc] rewriterule ^ http://www.%{http_host}%{request_uri} [r=301,l,ne] rewriterule ^([a-z0-9-]+)/?$ /index.php?cat=$1 [l,nc,qsa]
i keep current functionality , add 2 things like:
- (keep) redirecting address without variable domain.com/splash
- (keep) redirecting of address without www address www (http://domain.com/xx http://www.domain.com/xx)
- (keep) make rewrite http://www.domain.com/aa http://www.domain.com/index.php?cat=aa
- (add) make rewrite http://www.domain.com/aa/bb http://www.domain.com/index.php?cat=aa&product=bb
- (add) remove trailing slash @ end if present
you can use:
rewriteengine on rewriterule ^$ /splash [l,r=301] rewritecond %{http_host} ^domain\.com$ [nc] rewriterule ^ http://www.%{http_host}%{request_uri} [r=301,l,ne] rewritecond %{request_filename} !-d rewritecond %{the_request} \s(.+?)/+[?\s] rewriterule ^(.+?)/$ /$1 [r=301,l] rewriterule ^([a-z0-9-]+)/?$ /index.php?cat=$1 [l,nc,qsa] rewriterule ^([a-z0-9-]+)/([a-z0-9-]+)/?$ /index.php?cat=$1&product=$2 [l,nc,qsa]
Comments
Post a Comment