Redirect using Htaccess

Redirect using Htaccess

by Sarel van der Merwe -
Number of replies: 5
I’m trying to redirect the
1. divert http (80) to https 443
2. must redirect server root to sub folder https://www.domain/edu

I installed moodle in root with a sub folder  https://www.domain/edu

my . htaccess code

what is does, its only redirect http://domain to https://www.domain/edu/ and no https gets directed to edu when submitting  https://www.domain

 RewriteEngine On
 RewriteCond %{SERVER_PORT} 80
 RewriteRule ^(.*)$ https://www.domain/edu/$1 [R,L]


 thanks
Average of ratings: -
In reply to Sarel van der Merwe

Re: Redirect using Htaccess

by Ken Task -
Picture of Particularly helpful Moodlers

Try:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]

Remove the 'edu/' in yours.

'SoS', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Re: Redirect using Htaccess

by Sarel van der Merwe -
Thx for responding. It must also redirect to the subfolder edu. Moodle installed in subfolder edu from the root https://www.yourdomain.com/edu/ 


Thx

In reply to Sarel van der Merwe

Re: Redirect using Htaccess

by Ken Task -
Picture of Particularly helpful Moodlers

See

https://help.dreamhost.com/hc/en-us/articles/215747748-How-can-I-redirect-and-rewrite-my-URLs-with-an-htaccess-file-

Keep what you have to redirect port but add:

RewriteRule ^$ /edu/ [L]
From url above:

Automatically loading a subdirectory

This example redirects the ROOT domain's URL to any subdirectory. In this example, it automatically loads example.com/subdir1:

RewriteEngine on
RewriteRule ^$ /subdir1/ [L]
For good measure, restart apache service. smile

'SoS', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Re: Redirect using Htaccess

by Sarel van der Merwe -
Thankyou so much,,,, it worked.
In reply to Sarel van der Merwe

Re: Redirect using Htaccess

by Ken Task -
Picture of Particularly helpful Moodlers

Glad to hear it ... now a thought ... if one doesn't force to /edu/ but uses an index.php flle that auto-forwards to /edu/ or a static page with a link ... that would allow you to install a 'dev' moodle in /dev/.  /dev/ would be a small instance where admins could try out plugins etc.

My 2 cents!

'SoS', Ken