brendanheywood / moodle-local_cleanurls

Lets drag Moodle's url structure into this century...
36 stars 24 forks source link

.htaccess example for subfolders doesn't seem right #127

Open Arantor opened 6 years ago

Arantor commented 6 years ago

In the readme there is an example for using this in a subfolder - but I'm not entirely sure it routes correctly with RewriteBase / and then rewriting at the folder level.

I ended up creating an .htaccess file that lives in /moodle34/ as follows:

   # Enable RewriteEngine
   RewriteEngine on
   # All relative URLs are based from root
   RewriteBase /moodle34/
   # Do not change URLs that point to an existing file.
   RewriteCond %{REQUEST_FILENAME} !-f
   # Do not change URLs that point to an existing directory.
   RewriteCond %{REQUEST_FILENAME} !-d

   # Rewrite URLs matching ^(.*)$ as $1 - this means all URLs.
   # Rewrite it to the cleanurls router
   # Use ?q=$1 to forward the original URL as a query parameter
   # Use the flags:
   # - L (do not continue rewriting)
   # - B (encode back the parameters)
   # - QSA (append the original query string parameters)
   RewriteRule ^(.*)$ local/cleanurls/router.php?q=$1 [L,B,QSA,END]

This seems to solve the issue, without having the rewrite scope being weird... I don't think I've missed anything but would be interested to know if there's a difference.