Last active
January 1, 2020 01:10
-
-
Save khalwat/543b541eabf7443d003cb43f17d6a53e to your computer and use it in GitHub Desktop.
How to avoid .htaccess completely, and put your rewrite rules for Craft CMS in an Apache .conf file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Using .htaccess is something you should avoid if at all possible, due to performance concerns: | |
# https://httpd.apache.org/docs/current/howto/htaccess.html | |
# Here's how to implement the rewrite rules for CraftCMS in an Apache .conf file; the key | |
# part is the "## Removes index.php from Craft URLs ##" section; the rest is provided | |
# just for context. Enjoy - [email protected] | |
<VirtualHost *:80> | |
ServerName BradsForMen.com | |
ServerAlias *.BradsForMen.com | |
DocumentRoot /var/www/BradsForMen/public | |
CustomLog /var/log/httpd/BradsForMen.com-access.log combined | |
ErrorLog /var/log/httpd/BradsForMen.com-error.log | |
## Canonical domain rewrite ## | |
<If "%{HTTP_HOST} != 'BradsForMen.com'"> | |
Redirect "/" "http://BradsForMen.com/" | |
</If> | |
<Directory /var/www/BradsForMen> | |
Options FollowSymLinks | |
AllowOverride None | |
## Removes index.php from Craft URLs ## | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
# Send would-be 404 requests to Craft | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC] | |
RewriteRule ^(.+) /index.php?p=$1 [QSA,L] | |
</IfModule> | |
</Directory> | |
</VirtualHost> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment