Reputation: 11
Below is my htaccess config
RewriteEngine On # if the domain starts with "apply." # i.e. apply.domain.com # redirect to application URI RewriteCond %{HTTP_HOST} ^apply\. [NC] RewriteRule !^formwizard /formwizard/apply [R=301,L,NC]
I have tried it, and when I go to http://apply.domain.com/ it successfully redirects to http://apply.domain.com/formwizard/apply. My problem is, once it redirects to that URI, it goes to a redirect loop. Can anyone please help hit me what is wrong with my config?
Background: I have 3 subdomains: www.domain.com, apply.domain.com, and admin.domain.com. It all references to the same source codes and just managed by my htaccess. Once the person goes to apply.domain.com, it should be redirected to the application page which is /formwizard/apply.
PS. I don't want to depend too much on the backend codes because I believe this is a server config problem.
Thanks in advance!
Upvotes: 1
Views: 587
Reputation: 785641
If there are more rules then this rule might be getting impacted by them. Modify this rule to this:
RewriteCond %{HTTP_HOST} ^apply\. [NC]
RewriteCond %{THE_REQUEST} !/formwizard/ [NC]
RewriteRule ^ /formwizard/apply [R=301,L,NC]
Also make sure this is very first rule below RewriteEngine On
line.
Upvotes: 1