mrpatg
mrpatg

Reputation: 10117

properly structuring an htaccess with multiple rules/conds

How would i properly structure this htaccess file as to correctly function in order and avoid infinite loops?

RewriteEngine on 
RewriteCond %{HTTP_HOST} !^www.domain.com$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301]
RewriteBase /
RewriteRule ^deviceToken/$ devicetoken.php [QSA,L]
RewriteRule ^register/$ register.php [QSA,L]
RewriteRule ^resetPassword/$ resetpassword.php [QSA,L]
RewriteRule ^deleteLink/$ deletelink.php [QSA,L]
RewriteRule ^getLinks/$ getlinks.php [QSA,L]
RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)|(\.swf)|(\.xpi)|(\.ico)|(\.src)$ 
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteRule (.*)$ get.php?code=$1 [L]

Upvotes: 0

Views: 276

Answers (1)

Lekensteyn
Lekensteyn

Reputation: 66465

It looks OK, have you tried it already?

This line is useless:

RewriteCond %{REQUEST_URI} ^(.*)$

Redirect domain first:

RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

(added ,L)

Upvotes: 1

Related Questions