skip to Main Content

I add rewriterule to my .htacces file to add ‘www’ to my website, now they add www but I get always this error 500

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

2

Answers


  1. You should add an A record with www
    The redirect you added is just redirecting your site abc.com to http://www.abc.com .. but in the backend, on server, www points nowhere.
    So you should go to your DNS settings and add an “A” record with domain www , type A record and point to the IP address of your server.
    Hope that helps.

    Login or Signup to reply.
  2. You are getting a 500 internal server error/infinite loop error because your rule RewriteRule . /index.php [L] rewrites all requests (including /index.php ) to /index.php . In order to solve this , You need to exclude the Uri you are rewriting to :

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www.
    RewriteCond %{HTTPS}s ^on(s)|
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    #rewrite all to /index.php excluding `/index.php the destination uri
    RewriteCond ℅{REQUEST_URI} !/index.php$ [NC]
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search