Redirect using Htaccess

Redirect using Htaccess

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
評比平均分數: -
In reply to Sarel van der Merwe

Re: Redirect using Htaccess

Ken Task發表於
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

評比平均分數:Useful (1)
In reply to Ken Task

Re: Redirect using Htaccess

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

Ken Task發表於
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. 微笑

'SoS', Ken

評比平均分數:Useful (1)
In reply to Ken Task

Re: Redirect using Htaccess

Sarel van der Merwe發表於
Thankyou so much,,,, it worked.
In reply to Sarel van der Merwe

Re: Redirect using Htaccess

Ken Task發表於
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