Advertisement
reenadak

htaccess_tips

Sep 25th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.03 KB | None | 0 0
  1. <IfModule mod_rewrite.c>
  2. RewriteEngine On
  3.  
  4. #  ^ represent beggining and $ represent end and hence ^$ meaning anything.
  5. #  and hence anything here will be redirected to public folder ( public will prepend ) in url.
  6. RewriteRule ^$ public/ [L]
  7.  
  8. # .* just matches all the characters.
  9. RewriteRule (.*) public/$1 [L]
  10.  
  11. </IfModule>
  12.  
  13.  
  14.  
  15. ## EXPIRES CACHING ##
  16.  
  17. ExpiresActive On
  18. ExpiresByType image/jpg "access plus 1 year"
  19. ExpiresByType image/jpeg "access plus 1 year"
  20. ExpiresByType image/gif "access plus 1 year"
  21. ExpiresByType image/png "access plus 1 year"
  22. ExpiresByType text/css "access plus 1 month"
  23. ExpiresByType application/pdf "access plus 1 month"
  24. ExpiresByType text/x-javascript "access plus 1 month"
  25. ExpiresByType application/x-shockwave-flash "access plus 1 month"
  26. ExpiresByType image/x-icon "access plus 1 year"
  27. ExpiresDefault "access plus 2 days"
  28.  
  29. ## EXPIRES CACHING ##
  30.  
  31. <IfModule mod_deflate.c>
  32. AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
  33.  
  34. Options +FollowSymlinks
  35. Redirect /md /mate/index.php
  36. RewriteRule . /index.php [L]
  37.  
  38. RewriteEngine on
  39. RewriteBase /
  40. IndexIgnore *
  41.  
  42. RewriteCond %{REQUEST_FILENAME} !-f
  43. RewriteCond %{REQUEST_FILENAME} !-d
  44. RewriteRule ^([a-z0-9A-Z_-]+)$ /assets/php/show.php?slug=$1
  45. </IfModule>
  46.  
  47.  
  48. # custom error documents
  49. ErrorDocument 401 /md/err/401.php
  50. ErrorDocument 403 /md/err/403.php
  51. ErrorDocument 404 /md/err/404.php
  52. ErrorDocument 500 /md/err/500.php
  53.  
  54. <ifModule mod_expires.c>
  55.  
  56. RewriteRule ^dv([0-9]+) /diary.php?recid=$1&ACTION=VIEW [NC]
  57.  
  58. # If subdomain www exists, remove it first
  59. RewriteCond %{HTTP_HOST} ^www.([^.]+.[^.]+)$ [NC]
  60. RewriteRule ^(.*)$ http://%1/$1 [R=301]
  61.  
  62. # If requested resource does not exist as a file
  63. RewriteCond %{REQUEST_FILENAME} !-f
  64.  
  65. # and does not end with a period followed by a filetype
  66. RewriteCond %{REQUEST_URI} !..+$
  67.  
  68. # and does not end with a slash
  69. RewriteCond %{REQUEST_URI} !/$
  70.  
  71. # then add a trailing slash and redirect
  72. RewriteRule (.*) $1/ [R=301]
  73.  
  74. </IfModule>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement