What is the right way to redirect all traffic to HTTPS?

Number 1 If you want your website to be ONLY accessible through HTTPS, you will want to add this piece of code to your .htaccess file, replacing your domain’s name: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.example.com/$1 [R,L] </IfModule> This will redirect any visits from non-SSL to SSL version of your website. … Read more

Drawbacks to using Options -Indexes

There are some legitimate use cases for enabling Indexes but they’re probably not applicable to most sites (especially WordPress sites). For example Indexes are helpful on file storage mirrors where you want to provide readonly access to a subset of folders & files without having to build your own UI. As a best practice, yes, … Read more

301 Redirects Result in 404 for WordPress Search Query Strings

Redirect 301 /search?q=avengers https://www.example.com/?s=avengers You can’t match the query string with a mod_alias Redirect (or RedirectMatch) directive. The Redirect directive matches the URL-path only. You need to use mod_rewrite and match against the QUERY_STRING server variable. For example: RewriteCond %{QUERY_STRING} ^q=avengers$ RewriteRule ^search$ /?s=avengers [R=301,L] This will need to go before the existing WordPress front-controller. … Read more

Redirect only posts to New Domain

Thanks everyone for taking time to look and get it solved. After so many trials and try-catch, I managed to achieve the above task by adding these lines to .htaccess RewriteCond %{HTTP_HOST} ^(www\.)?prsblog\.com$ [NC] #RewriteCond %{REQUEST_URI} !\.(jpe?g|png|gif|ico)$ [NC] RewriteCond %{REQUEST_URI} !wp-admin RewriteRule ^(.*)$ https://www.pyarb.com/$1 [L,R=301] This solved my problem for instant.

Preserve Domain Alias

You need to set the canonical hostname (ie. with www) in the WordPress dashboard… Under Settings > General and set the appropriate “WordPress Address (URL)” and “Site Address (URL)” properties. Alternatively, these values can be hardcoded in wp_config.php by defining the WP_HOME and WP_SITEURL constants respectively. Reference: https://codex.wordpress.org/Changing_The_Site_URL SSLOptions +StrictRequire SSLRequireSSL SSLRequire %{HTTP_HOST} eq “example.com” … Read more

403 error on admin login page

I managed to enter the admin page finally! So I added these two lines to wp_admin.php: define(‘WP_HOME’,’http://example.com’); define(‘WP_SITEURL’,’http://example.com’); afterward deleted the .htaccess file, then deleted browsing history, cleared cache and cookies. After all of this I could enter the admin page. Then I went to options/general and options/permalinks and saved the setting, it generated a … Read more