Created
May 31, 2019 14:32
-
-
Save terryupton/e98e6f37182c9abe3e526e5a90ebf2bd to your computer and use it in GitHub Desktop.
This file contains 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
I have the following in my .htaccess file | |
``` | |
<IfModule mod_rewrite.c> | |
Options +FollowSymlinks | |
# Options +SymLinksIfOwnerMatch | |
RewriteEngine On | |
RewriteBase / | |
# ------------------------------------------------------------------------------ | |
# | Redirect to top level /index.php to the root (www) | | |
# ------------------------------------------------------------------------------ | |
RewriteCond %{THE_REQUEST} ^.*/index.php | |
RewriteRule ^(.*)index.php$ /$1 [R=301,L] | |
# ------------------------------------------------------------------------------ | |
# | Add trailing slash to urls | | |
# ------------------------------------------------------------------------------ | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$ | |
RewriteRule ^(.*)$ $1/ [R=301,L] | |
# ------------------------------------------------------------------------------ | |
# | Remove .php-extension from urls | | |
# ------------------------------------------------------------------------------ | |
#This removes php extension | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule ^([^\.]+)/$ $1.php [NC,L] | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.php | |
RewriteRule (.*)\.php$ /$1/ [L,R=301] | |
</IfModule> | |
# ------------------------------------------------------------------------------ | |
# | Filename-based cache busting | | |
# ------------------------------------------------------------------------------ | |
# If you're not using a build process to manage your filename version revving, | |
# you might want to consider enabling the following directives to route all | |
# requests such as `/css/style.12345.css` to `/css/style.css`. | |
# To understand why this is important and a better idea than `*.css?v231`, read: | |
# http://stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring | |
<IfModule mod_rewrite.c> | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L] | |
</IfModule> | |
``` |
Thanks @j-greig.
Where as a .htaccess would sit in the root - where does this stuff live in terms of the project directory and naming etc?
I’m Using valet locally.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add a trailing slash:
rewrite ^/(.*)/$ /$1 permanent;
Cache-busting:
Check out https://github.com/nystudio107/nginx-craft/blob/master/nginx-partials/cache-busting.conf
And might be more clues for you at https://github.com/nystudio107/nginx-craft :)