.htaccess File
The .htaccess
file is a configuration file used by web servers to control site behavior such as redirects. With Modern Campus Hosting, you'll see a file named .htaccess
in your site’s home (root) folder. When you add simple, one-line directives to the file they apply to that folder and all its subfolders.
To get started, set file access to Administrators Only and Publish to Production to No. Then,
- Click to open the
.htaccess
file. - Add directives, with comments.
- See the next section for sample directives you can use.
- Save.
- Publish.
If you encounter an error after publishing, you can use page versions to restore a previous version.
Inside the FileLink to this section
Use redirects and error pages to improve your website user's experience.
Redirects
To set up a permanent (301) or temporary (302) redirect, use one of the following example directives to your .htaccess
file, placing each on its own line:
# Basic PERMANENT redirect
Redirect 301 /old-page.html /new-page.html
# OR
RewriteRule ^old-page\.html$ /new-page.html [R=301,L]
# Basic TEMPORARY redirect
Redirect 302 /old-page.html /new-page.html
# OR
RewriteRule ^old-page\.html$ /new-page.html [R=302,L]
Although RewriteRule
can be used alongside other directives, our team does not currently provide support for such configurations.
File Comments
To add a comment to the .htaccess
file, start the line with #
.
Need Help?Link to this section
Contact our CMS Support team via the Support Resource Portal (login required) to receive help with managing your .htaccess
file.