1

I know this is a duplicate question but I tried all the answers here on stackoverflow and many results on google but nothing works.I even tried to use this htaccess redirect generator http://www.htaccessredirect.com/ that gave me this code

## Rewrite to www
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^a.solutionbanks.com[nc]
RewriteRule ^(.*)$ http:## www.a.solutionbanks.com/$1 [r=301,nc]

that also didn't work. all what I am trying to do is to redirect from a.solutionbanks.com to --> www.a.solutionbanks.com

Cœur
  • 37,241
  • 25
  • 195
  • 267
user3571278
  • 721
  • 5
  • 15
  • As far as I know it's easier to do this using a `ServerAlias` (if you are using Apache atleast..) look here: [Serveralias](http://stackoverflow.com/questions/586129/create-subdomains-on-the-fly-with-htaccess-php) – Azrael Sep 22 '14 at 05:35

1 Answers1

0

Your syntax is wrong at many places. Try this rule:

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^a\.solutionbanks\.com$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=301]

Reference: Apache mod_rewrite Introduction

Apache mod_rewrite Technical Details

anubhava
  • 761,203
  • 64
  • 569
  • 643
  • not working.. when I open a.solutionbanks.com it redirects me to http://www.a.solutionbanks.com/a/ – user3571278 Sep 22 '14 at 06:23
  • Verify whether your `.htaccess` is enabled or not, by putting same garbage (random) text on top of your `.htaccess` and see if it generates 500 (internal server) error or not? – anubhava Sep 22 '14 at 06:33
  • yes i am sure my .htaccess is enabled. i have used it before and this time its working but the result is not correct becaause the code is wrong – user3571278 Sep 22 '14 at 06:42
  • What code is wrong? Did you do verification as I told and got 500 as a result? If you have other rules then make sure this rule is places as very first rule. – anubhava Sep 22 '14 at 06:43
  • yes i did the verification the .htaccess is enabeled no i dont have other rules currently – user3571278 Sep 22 '14 at 06:44
  • It is not working because you are using `nginx/1.6.2` which is not Apache. – anubhava Sep 22 '14 at 06:45
  • [This should help you](http://stackoverflow.com/questions/25967574/shell-script-grep-command-for-wild-cards) – anubhava Sep 22 '14 at 06:53
  • but how is the .htaccess working without apache? it was working before and actually its working now when i open a.solutionbanks.com/tools/sendmail.php it redirects to www.a.solutionbanks.com/tools/sendmail.php its only the homepage thats not working – user3571278 Sep 22 '14 at 07:00
  • a.solutionbanks.com/index.php redirect correctly but a.solutionbanks.com redirects to www.a.solutionbanks.com/a thats the only wrong one – user3571278 Sep 22 '14 at 07:01
  • I just tested and `http://a.solutionbanks.com` got redirected to `http://www.a.solutionbanks.com/` and there was no `/a/` in the end. Make sure to test in a new browser to avoid old cache. – anubhava Sep 22 '14 at 07:08