Question

htaccess rewrite not working in WordPress. Any ideas?

#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]

Show comments

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

@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.

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.