Report this

What is the reason for this report?

htaccess rewrite not working in WordPress. Any ideas?

Posted on May 23, 2017

#RewriteEngine On #RewriteCond %{HTTP:X-Forwarded-Proto} !https #RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

RewriteEngine on RewriteCond %{HTTP_HOST} ^www.mrtownhome.net [NC] RewriteRule ^(.*)$ http://mrtownhome.net/$1 [L,R=301]

RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @frankbiganski

What is it that isn’t working?

It seems like your domain is pointing to different locations. www.mrtownhome.net to InMotion Hosting mrtownhome.net to CloudWays on DigitalOcean

And you’re running both Nginx and Apache - as far as I can tell, which adds extra configuration overhead, which might be more difficult to setup correctly.

@frankbiganski

How it should be setup really depends on what you’re trying to do :-).

In the example you’ve posted, RewriteEngine On exists three times. Keep it at the top of the file and remove the other two instances of that line.

That should leave us with:

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^www.mrtownhome.net [NC]
RewriteRule ^(.*)$ http://mrtownhome.net/$1 [L,R=301]

RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUESTFILENAME} !-f
RewriteCond %{REQUESTFILENAME} !-d
RewriteRule . /index.php [L]

With that, is this particular instance behind a proxy? I’m asking due to the second line. If so, then you may very well need a bit of code in wp-config.php to handle this instead of .htaccess.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.