Change your configuration to this (add a slash):
RewriteCond %{HTTP_HOST} ^example.com$ [NC] RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Or the solution outlined below (proposed by @absiddiqueLive) will work for any domain:
RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
If you need to support http and https and preserve the protocol choice try the following:
RewriteRule ^login\$ https://www.%{HTTP_HOST}/login [R=301,L]
Where you replace login
with checkout.php
or whatever URL you need to support HTTPS on.
I’d argue this is a bad idea though. For the reasoning please read this answer.
Related Posts:
- How to remove .html from URL?
- How to remove .html from URL?
- Change PHP version on server using either .htaccess or php.ini
- Access-Control-Allow-Origin Multiple Origin Domains?
- wordpress image upload error and htaccess rule explanation
- .htaccess Remove WWW from URL + Directories
- CodeIgniter removing index.php from url
- .htaccess deny from all
- Server unable to read htaccess file, denying access to be safe
- Generic htaccess redirect www to non-www
- Using Errordocument 401 leads to blank page
- How to avoid Request Entity Too Large 413 error
- How to redirect all HTTP requests to HTTPS
- How can I use an .htaccess file in Nginx?
- .htaccess redirect http to https
- .htaccess – how to force “www.” in a generic way?
- Redirect vs RedirectMatch
- How to automatically redirect HTTP to HTTPS on Apache servers?
- SSL_ERROR_BAD_CERT_DOMAIN
- htaccess – Redirect to subfolder without changing browser URL
- Mixed Content Page: requested an insecure stylesheet error
- The requested URL /about was not found on this server
- How does RewriteBase work in .htaccess
- How do I disable directory browsing?
- Https to http redirect using htaccess
- Getting a 500 Internal Server Error on Laravel 5+ Ubuntu 14.04
- How to remove index.php from WordPress site URL
- .htaccess: Invalid command ‘RewriteEngine’, perhaps misspelled or defined by a module not included in the server configuration
- Redirect old php link to wordpress link in .htaccess
- Redirect old php link to wordpress link in .htaccess
- Safely redirect old WordPress blog links to new WP blog
- Double slashes on WordPress Admin URL redirects to wp-login
- Cant login to wp-admin (redirecting to homepage), But CAN login to wp-login.php
- Cant login to wp-admin (redirecting to homepage), But CAN login to wp-login.php
- WordPress- url for localhost wp-admin is not working
- WordPress- url for localhost wp-admin is not working
- WordPress maintenance mode .htaccess
- How to modify HTACCESS file for non-WordPress documents
- Best collection of code for your .htaccess file [closed]
- Cannot access non-wordpress subdirectories as wordpress overrides them with a 404 error
- How to create custom 401, 403 and 500 error pages?
- Site Redirecting to wp-signup.php
- Moving a WP Multisite to a subdirectory
- “Too many redirects” ONLY when trying to access wp-admin page
- Default .htaccess file for WordPress?
- How do I skip wordpress’s 404 handling and redirect all 404 errors for static files to 404.html?
- WordPress Redirect All HTTP requests to HTTPS via .htaccess
- Redirect entire website to a single page
- Which one does WordPress prioritize when it comes to php.ini, wp-config and .htaccess?
- Masking wp-content/themes/name/images to just images directory using htaccess
- Improve wordpress security by hiding non public resources
- Security and .htaccess
- Passing parameters to a custom page template using clean urls
- Use author author display name in permalink structure for pages and posts
- WordPress site hacked. Has .htaccess been hacked?
- Does this .htaccess security setting really work?
- Setting up WordPress with Custom Permalinks and no .htaccess File?
- Does WordPress Change the .htaccess File When Updating?
- Use a different domain for SSL
- How to add custom rewrite rule to .htaccess?
- Use subdomain for certain urls
- Combining Multiple Taxonomies in one URL
- htaccess problem after saving Settings
- multisite 404 error for subdirectory
- Protecting direct access to PDF and ZIP unless user logged in (without plugin)
- Multisite htaccess on localhost with WP as an SVN external?
- Stop WordPress and Plugins from Overwriting .htaccess
- Move WordPress to subdirectory, keep ALL URLs
- How to stop wordpress from changing default .htaccess permissions to 444
- .htaccess in wp-admin produces a redirect loop
- Change Login URL Without Plugin
- File and directory permissions
- htaccess disable WordPress rewrite rules for folder and its contents
- WP-Admin not working properly at WordPress multisite with subdirectories
- htaccess rewrite conflict with wordpress rules and ssl
- Clash of the rewrites
- How to remove category from wordpress url?
- 301 Redirects for Changed Permalink Structure & Category Base
- Old blog/ and blog/feed/ URLs not working after moving blog to top-level via .htaccess
- How Do I Programmatically Force Custom Permalinks with My Theme?
- Non-WordPress page in subdirectory under WordPress page
- Permalinks to Custom does not work (out of box)
- Edit or Remove Plugin .htaccess Using The Admin Panel
- htaccess https redirect from www to non-www
- Force HTTPS using .htaccess – stuck in redirect loop
- WordPress permalinks Yahoo hosting(no .htaccess allowed)
- What does a security risk in a plugin look like?
- PHP – redirect https to http and www to non-www
- How do I turn off 301 redirecting posts (not canonical)?
- Permalink Issues by Installing WordPress in Subdirectory / Subfolder
- Allow admin login at /admin
- Htaccess for Wordpess set on single subdomain
- Securing wp-admin folder – Purpose? Importance?
- Passing variables through permalink structure
- adding rewrite rules in .htaccess
- Redirecting WordPress /.htaccess / HSTS / SSL
- 301 redirect not working through .htaccess
- .htaccess and 500 error, extra character added
- WordPress .htaccess subdirectory problem
- Wrong canonical link on wp-admin pages