Rules and redirects with htaccess
htaccess is a powerful tool that manages your site's URL structure and other settings. You can use it to create custom redirects, "vanity URLs", and define settings for templates. To edit htaccess, visit Admin > htaccess. You must have Site Administrator privileges for the site in order to use this tab.
How the CMS works with htaccess
Whenever new content is published, that site's htaccess file is rewritten to add a URL for the page. Therefore, any of your own custom htaccess rules must be added via the CMS htaccess tool for them to be included in the file. Rules entered into the .htaccess file manually via FTP will be overwritten in the near future the next time new content is published.
Creating a custom redirect
One common use of htaccess is to create custom URL redirects. Sometimes you may want to promote a simpler URL like http://yoursite.com/strategy instead of http://yoursite.com/resources/strategic-plan.
To create this redirect, go to Admin > Site > htaccess and enter a new line:
Redirect /strategy /resources/strategic-plan
In Redirect syntax, there needs to be a space in between "Redirect", the custom URL ("/strategy") and the full URL ("http://www.yoursite.com/resources/strategic-plan").
Existing pages
Redirects may not work as expected if there is a Page in the Pages module which is already using the URL that you wish to redirect. So, in our example, there should not be a Page already using the URL "/strategy". If there was, you may place the Page into Draft mode and the URL will be free for use again.
Dealing with a trailing slash
Our system will automatically add a trailing slash to the end of every url. This can cause issues with redirects, since sometimes you may want to redirect to a url that includes a query string parameter. You can disable this functionality when writing your redirect rule. If the first half of the redirect rule includes a trailing slash, but the second url does not contain a trailing slash, the system will properly redirect without the trailing slash.
Redirect /strategy/ http://example.com/resources/no-trailing-slash
htaccess comments
You can safely add a note (called a comment) inside htaccess by beginning a line with a hash "#" sign. You can also disable existing rules this way, keeping the rule handy for the future.
# Redirect /conference /event/our-big-conference-2018/
htaccess errors
Rules using "Redirect" or "RewriteRule" will be marked with ###ERROR### if the proper syntax for the rule is not used. To enable these rules, correct any syntax issues and also remove ###ERROR### from the beginning of the line.
Apache documentation
Here you can find the related official documentation for Apache HTTP Server v2.4, used by Ekklesia 360: