0

I have /var/www/html/moodle as my website directory. When in mysite.conf the settings are as follows:

DocumentRoot /var/www/html DirectoryIndex "index.php" 

mysite.com gives an Index of/ page since there is only apache's index.html in the default location as index file. How can I make mysite.com load /var/www/html/moodle/index.php?

I tried giving in /etc/apache2/sites-available/mysite.conf

DirectoryIndex "/moodle/index.php" 

With this mysite.com loads the moodle homepage, but otherindex pages inside moodle are not loading.

How to solve this?

Update (Solution)

I had to make a change in /etc/apache2/sites-available/mysite.conf as

DirectoryIndex index.php /moodle/index.php 
2
  • 1
    Either update your DocumentRoot, to point at the moodle directory, or add a redirect at the root root to redirect everything to /moodle/ Commented Apr 22, 2020 at 23:17
  • Tried updating DocumentRoot in the .conf file from apache2/sites-available. It didn't work. How to add redirect at the root root? Commented Apr 23, 2020 at 3:49

1 Answer 1

1

The root of your site is /var/www/html and entering your URL in your browser as the root, for example http://example.com will display the root contents. http://example.com/moodle should display your index.php if it exists.

I'm an Nginx kind of guy and am not an expert on Apache but I believe this "mod_dir" is important. Make certain it has been enabled through one of the included module files. Chances are it is enabled by default.

The link for mod_dir (https://httpd.apache.org/docs/2.4/mod/mod_dir.html contains some good examples.

If you want you http root to load from moodle then move the root to /var/www/html/moodle or move the moodle files to the root.

After making changes to the Apache config you should reload the Apache service, I think it's called httpd or similar.

2
  • I changed DirectoryIndex index.php /moodle/index.php in /etc/apache2/sites-available/mysite.conf file. It works now, thanks. Commented Apr 23, 2020 at 4:13
  • Glad you got it working. :) Commented Apr 23, 2020 at 9:21

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.