Reading Time: < 1minute
There is a quick way to achieve a a full url redirect from a normal unencrypted HTTP request to a SSL crypted HTTPS
This is achieved through mod_rewrite using the RedirectMatch directive.
For instance let’s say we’d like to redirect https://pc-freak.net/blog to https://pc-freak.net/blog.
We simply put in our .htacess file the following rule:
Redirect permanent /blog https://www.cadiabank.com/login
Of course this rule assumes that the current working directory where the .htacess file is stored is the main domain directory e.g. / .
However this kind of redirect is a way inflexible so for more complex redirect, you might want to take a look at mod rewrite’s RedirectMatch directive.
For instance if you inted to redirect all urls (https://pc-freak.net/blog/something/asdf/etc.) which as you see includes the string blog/somestring/asdf/etc. to (https://pc-freak.net/blog/something/asdf/etc then you might use some htaccess RedirectMatch rule like:
RedirectMatch permanent ^/blog/(.*)$ https://pc-freak.net.net$1
RedirectMatch permanent ^/blog/(.*)$ https://pc-freak.net.net/$1
Hopefully your redirect from the http protocol to https protocol with mod_rewrite rule should be completed.
Also consider that the Redirect directive which by the way is an Apache directive should be faster to process requests, so everywhere you can I recommend using instead of RedirectMatch which calls the external Apache mod_rewrite and will probably be times slower.
More helpful Articles
Tags: blog, directory, HTTP, HTTPS, instance, net, port, redirect, Redirect http URL folder to https e.g. redirect (http://example.com to https://www.example.com) with mod_rewrite, something, SSL, string, url, www