-2

I am working on the Moodle I want to change the permalinks like Wordpress. I want to use the page name as URL suffix. mod_rewrite not working for me.

from

www.domain.com/mod/page/view.php?id=431

to

www.domain.com/aboutus

what is the possibility that I can do this? I researched on moodle docs but no success.

Umer bin Siddique
  • 460
  • 1
  • 4
  • 13
  • Possible duplicate of [Reference: mod\_rewrite, URL rewriting and "pretty links" explained](https://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained) – Richard Parnaby-King Jul 18 '17 at 14:51

2 Answers2

1

Try this in your .htaccess:

RewriteEngine On
RewriteRule ^aboutus$ /mod/page/view.php?id=431 [L]

This should take the URL www.domain.com/mod/page/view.php?id=431 and leave you with www.domain.com/aboutus.

Make sure you clear your cache before you test this.

If you have issues with the above, you can try it using {QUERY_STRING}:

RewriteCond %{QUERY_STRING} id=431$ 
RewriteRule (.*) /aboutus/? [R=301,L]
Joe
  • 4,877
  • 5
  • 30
  • 51
0

If your moodle running in apache server, then place .htaccess file in root folder

In .htaccess file

# Enable mod_rewrite
RewriteEngine On

# The path to the Moodle instance e.g. /moodle/
RewriteBase /

##############################  COURSE  ##############################

# course/{name,idnumber,id}/<value of the provided key>
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule course/([^\/]+)\/(.+)$  course/view.php?$1=$2 [L,QSA]

# course/<id, i.e. Moodle magic number>
#
RewriteCond %{REQUEST_URI}          course/([\d]+)$ [NC]
RewriteRule course/(.+)$            course/view.php?id=$1 [L,QSA]

# course/<value, i.e. shortname>
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI}          course/([^\d]+)$ [NC]
RewriteRule course/(.+)$            course/view.php?name=$1 [L,QSA]
#
######################################################################

Or Easiest way is use this module. https://github.com/brendanheywood/moodle-local_cleanurls

Naveen DA
  • 4,148
  • 4
  • 38
  • 57