Moodle Redirect

Moodle Redirect

by Armando Silva -
Number of replies: 4

Hello. My goal is to redirect a course url, but I am having trouble.


I am running httpd-2.4.6-45.el7.centos.4.x86_64 and moodle 3.3

I tried putting this in [docroot]/.htaccess:

DirectoryIndex index.php index.html index.htm

php_value memory_limit 40M

php_flag magic_quotes_gpc 1

php_flag magic_quotes_runtime 0

php_flag file_uploads 1

php_flag session.auto_start 0

php_flag session.bug_compat_warn 0

<IfDefine APACHE2>

    AcceptPathInfo on

</IfDefine>

# Turn mod_rewrite on

RewriteEngine On

RewriteBase /

RewriteCond %{HTTP_HOST} ^[my website ip address]$ [NC]

RewriteRule ^learn/course/index\.php?categoryid=13$ http://www.google.com [L,R=301,NC]


But that did nothing. So then I tried putting stuff in httpd.conf

<IfModule mod_rewrite.c>

   RewriteCond %{REQUEST_URI} ^/learn/course/index.php

   RewriteCond %{QUERY_STRING} categoryid=17

   RewriteRule (.*) https://www.google.com [R=301,L]

</IfModule>


But this does nothing either. I am wondering is it because /learn/course/index.php?categoryid=17 has queried string?



Average of ratings: -
In reply to Armando Silva

Re: Moodle Redirect

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Can you back up and explain what problem you are trying to solve... what do you mean by 'redirect' here? Redirect from where?

In reply to Howard Miller

Re: Moodle Redirect

by Armando Silva -

Hi Howard. I mean redirect from an internal page to an external page. I just figured out my question. It did have to do with the queried string in the url. 

I was trying to go from /learn/course/index.php?categoryid=17 to http//www.google.com


I wrote this in moodle/.htaccess:

# Turn mod_rewrite on

RewriteEngine on

RewriteCond %{REQUEST_URI} ^/learn/course/index\.php$

RewriteCond %{QUERY_STRING} ^categoryid=17$

RewriteRule (.*) https://www.google.com [R=301,L]


 And worked like a charm. Thank you for responding.

In reply to Armando Silva

Re: Moodle Redirect

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I can't imagine why you would want to do that...

In reply to Howard Miller

Re: Moodle Redirect

by Armando Silva -

Because the course that is being redirected is on a different web site, google.com was just a place holder for another external url.