|
1 | 1 | # Enable this line to temporarily disable the Apache rewrite cache. |
2 | 2 | #Header set Cache-Control "max-age=0, private, no-store, no-cache, must-revalidate" |
3 | 3 |
|
4 | | -RewriteEngine On |
| 4 | +# Tell PHP that we are using Apache |
| 5 | +SetEnv SERVER_TYPE Apache |
5 | 6 |
|
6 | | -# www. to non-www. |
7 | | -RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] |
8 | | -RewriteRule ^(.*)$ http://%1/$1 [R=301,L] |
| 7 | +<IfModule mod_rewrite.c> |
9 | 8 |
|
10 | | -# Remove trailing slash from any non-directory path (canonicalization) |
11 | | -RewriteCond %{REQUEST_FILENAME} !-d |
12 | | -RewriteCond %{REQUEST_URI} (.+)/$ |
13 | | -RewriteRule ^ %1 [L,R=301] |
| 9 | + # Tell PHP that the mod_rewrite module is ENABLED. |
| 10 | + SetEnv HTTP_MOD_REWRITE On |
14 | 11 |
|
15 | | -# Dynamically rewrite base directory (see http://stackoverflow.com/questions/31062479/301-redirect-urls-that-are-also-being-rewritten) |
16 | | -RewriteCond $0#%{REQUEST_URI} ^([^#]*)#(.*)\1$ |
17 | | -RewriteRule ^.*$ - [E=BASE:%2] |
18 | | - |
19 | | -# Forward any requested URLs that specifically contain index.php (see http://stackoverflow.com/questions/31062479/301-redirect-urls-that-are-also-being-rewritten) |
20 | | -RewriteCond %{THE_REQUEST} /index\.php [NC] |
21 | | -RewriteRule ^index\.php(?:/(.*))?$ %{ENV:BASE}$1 [L,R=301,NC,NE] |
22 | | - |
23 | | -# Send the URI to index.php (Slim routing) |
24 | | -RewriteCond %{REQUEST_FILENAME} !-f |
25 | | -RewriteRule ^ index.php [QSA,L] |
| 12 | + RewriteEngine On |
| 13 | + |
| 14 | + # Forward all www. to non-www. Remove this rule if you want both available. |
| 15 | + RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] |
| 16 | + RewriteRule ^(.*)$ http://%1/$1 [R=301,L] |
| 17 | + |
| 18 | + # Remove trailing slash from any non-directory path (canonicalization) |
| 19 | + RewriteCond %{REQUEST_FILENAME} !-d |
| 20 | + RewriteCond %{REQUEST_URI} (.+)/$ |
| 21 | + RewriteRule ^ %1 [L,R=301] |
| 22 | + |
| 23 | + # Dynamically rewrite base directory (see http://stackoverflow.com/questions/31062479/301-redirect-urls-that-are-also-being-rewritten) |
| 24 | + RewriteCond $0#%{REQUEST_URI} ^([^#]*)#(.*)\1$ |
| 25 | + RewriteRule ^.*$ - [E=BASE:%2] |
| 26 | + |
| 27 | + # Forward any requested URLs that specifically contain index.php (see http://stackoverflow.com/questions/31062479/301-redirect-urls-that-are-also-being-rewritten) |
| 28 | + RewriteCond %{THE_REQUEST} /index\.php [NC] |
| 29 | + RewriteRule ^index\.php(?:/(.*))?$ %{ENV:BASE}$1 [L,R=301,NC,NE] |
| 30 | + |
| 31 | + # Send the URI to index.php (Slim routing) |
| 32 | + RewriteCond %{REQUEST_FILENAME} !-f |
| 33 | + RewriteRule ^ index.php [QSA,L] |
26 | 34 |
|
| 35 | +</IfModule> |
| 36 | + |
27 | 37 | # Deny access to any php.ini files |
28 | 38 | <Files php.ini> |
29 | 39 | Order allow,deny |
|
0 commit comments