Posted by CANbike on Tue, 15 Jul 2014

[Oxwall] .htaccess and Non-Oxwall Directories and Files

Oxwall, by default, does not like external directories and files. Any attempt to access a non-Oxwall URL results in a 404 Not Found error.

Fortunately this is all controlled by the .htaccess file.

Options +FollowSymLinks
RewriteEngine On

AddEncoding gzip .gz
AddEncoding gzip .gzip
<FilesMatch "\.(js.gz|js.gzip)$">
  ForceType text/javascript
</FilesMatch>
<FilesMatch "\.(css.gz|css.gzip)$">
  ForceType text/css
</FilesMatch>

RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_URI} !/ow_updates/index\.php
RewriteCond %{REQUEST_URI} !/ow_updates/
RewriteCond %{REQUEST_URI} !/ow_cron/run\.php
RewriteCond %{REQUEST_URI} !/e500\.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.xml|\.feed|robots\.txt|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php

Adding Exceptions

Exceptions are easy to add by including a RewriteCond before the last line

RewriteRule (.*) index.php

For example, Oxwall is installed at the domain imtb.ca. To make an exception, add the following code to the .htaccess file:

Subdomain

RewriteCond %{HTTP_HOST} !subdomain.imtb.ca$

Folder

RewriteCond %{REQUEST_URI} !/folder/

File

RewriteCond %{REQUEST_URI} !/file.html

Oxwall htaccess-Exceptions for Directiories Files Subdomains-thumb.png

URL “Username” Redirect

For vanity reasons, www.imtb.ca/CANbike should redirect to my user profile www.imtb.ca/user/CANbike. Moreover, it should be case insensitive.

To do that, the following was added to the end of the .htaccess file:

RewriteCond %{REQUEST_URI} ^/canbike [NC]
RewriteRule (.*) http://www.imtb.ca/user/CANbike

Related Item(s):