tags:

views:

11

answers:

1

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]
+1  A: 

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)

Lekensteyn
yeah, when i visit domain.com, instead of redirecting to www.domain.com, it redirects to http://www.domain.com/get.php?code=http://www.domain.com/
Patrick
You need two redirects then. See my edited post.
Lekensteyn