jrfnl/PHP-cheat-sheet-extended/master/.htaccess - Htaccess File

jrfnl/PHP-cheat-sheet-extended/master/.htaccess

# .htaccess voor phpcheatsheets.com

Options -Indexes -MultiViews

# Prevent users from opening and reading php include files
# Prevent users from viewing htaccess / htpasswd files
# Prevent users from viewing logfiles
<FilesMatch ".(htaccess|htpasswd|ini|phps|inc|log|sh|md|bak|bat|yml|gitignore|gitmodules|gitattributes)$">
 Order Allow,Deny
 Deny from all
</FilesMatch>

# Redirects for files which no longer exist
# 4.3.(0)9 => 4.3.11
RedirectMatch 301 /static_results/(arithmetic|compare|test)/php4.3.(0)?9.html$ http://phpcheatsheets.com/static_results/$1/php4.3.11.html

# 5.2.(0)4 => 5.2.6
RedirectMatch 301 /static_results/(arithmetic|compare|test)/php5.2.(0)?4.html$ http://phpcheatsheets.com/static_results/$1/php5.2.6.html

# 5.2.(0)8/9 => 5.2.9-2
RedirectMatch 301 /static_results/(arithmetic|compare|test)/php5.2.(0)?[89].html$ http://phpcheatsheets.com/static_results/$1/php5.2.9-2.html

# 5.3.02 / 5.3.2 => 5.3.3
RedirectMatch 301 /static_results/(arithmetic|compare|test)/php5.3.(0)?2.html$ http://phpcheatsheets.com/static_results/$1/php5.3.3.html

# 5.4.(0)6 => 5.4.4
RedirectMatch 301 /static_results/(arithmetic|compare|test)/php5.4.(0)?6.html$ http://phpcheatsheets.com/static_results/$1/php5.4.4.html

# 5.4.11/20 => 5.4.16
RedirectMatch 301 /static_results/(arithmetic|compare|test)/php5.4.(11|20).html$ http://phpcheatsheets.com/static_results/$1/php5.4.16.html

# 5.4.33/35/37 => 5.4.36
RedirectMatch 301 /static_results/(arithmetic|compare|test)/php5.4.3[357].html$ http://phpcheatsheets.com/static_results/$1/php5.4.36.html

# 5.4.39/42 => 5.4.41
RedirectMatch 301 /static_results/(arithmetic|compare|test)/php5.4.(39|42).html$ http://phpcheatsheets.com/static_results/$1/php5.4.41.html

# 5.4.43 => 5.4.45
RedirectMatch 301 /static_results/(arithmetic|compare|test)/php5.4.43.html$ http://phpcheatsheets.com/static_results/$1/php5.4.45.html

# 5.5.18 => 5.5.16
RedirectMatch 301 /static_results/(arithmetic|compare|test)/php5.5.18.html$ http://phpcheatsheets.com/static_results/$1/php5.5.16.html

# 5.5.20/21/24 => 5.5.22
RedirectMatch 301 /static_results/(arithmetic|compare|test)/php5.5.2[014].html$ http://phpcheatsheets.com/static_results/$1/php5.5.22.html

# 5.5.26/28 => 5.5.30
RedirectMatch 301 /static_results/(arithmetic|compare|test)/php5.5.2[68].html$ http://phpcheatsheets.com/static_results/$1/php5.5.30.html

# 5.6.2 => 5.6.0
RedirectMatch 301 /static_results/(arithmetic|compare|test)/php5.6.2.html$ http://phpcheatsheets.com/static_results/$1/php5.6.0.html

# 5.6.4/5/8/9 => 5.6.7
RedirectMatch 301 /static_results/(arithmetic|compare|test)/php5.6.[4589].html$ http://phpcheatsheets.com/static_results/$1/php5.6.7.html

# 5.6.10/11 => 5.6.13
RedirectMatch 301 /static_results/(arithmetic|compare|test)/php5.6.1[01].html$ http://phpcheatsheets.com/static_results/$1/php5.6.13.html

# 5.6.15/7 => 5.6.16
RedirectMatch 301 /static_results/(arithmetic|compare|test)/php5.6.1[57].html$ http://phpcheatsheets.com/static_results/$1/php5.6.16.html

# 5.6.19 => 5.6.20
RedirectMatch 301 /static_results/(arithmetic|compare|test)/php5.6.19.html$ http://phpcheatsheets.com/static_results/$1/php5.6.20.html

# 7.0.0alpha1/RC6 => 7.0.0
RedirectMatch 301 /static_results/(arithmetic|compare|test)/php7.0.0(alpha1|RC[1-8]).html$ http://phpcheatsheets.com/static_results/$1/php7.0.0.html

# 7.0.2 => 7.0.4
RedirectMatch 301 /static_results/(arithmetic|compare|test)/php7.0.2(alpha1|RC[1-8]).html$ http://phpcheatsheets.com/static_results/$1/php7.0.4.html

# Add 404 directives
ErrorDocument 403 /index.php?page=error&e=403
ErrorDocument 404 /index.php?page=error&e=404

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_METHOD} ^(HEAD|TRACE|DELETE|TRACK|DEBUG) [NC]
RewriteRule ^(.*)$ - [F,L]

# Redirect GET requests from the dropdown to html files
RewriteCond %{QUERY_STRING} page=(arithmetic|compare|test)&tab=([a-z0-9_-]+)&phpversion=(php[0-9.-]+((alpha|beta|RC)([0-9])?)?) [NC]
RewriteRule index.php /static_results/%1/%3.html#%2? [NE,R=301,L]

RewriteCond %{QUERY_STRING} page=(arithmetic|compare|test)&tab=&phpversion=(php[0-9.-]+((alpha|beta|RC)([0-9])?)?) [NC]
RewriteRule index.php /static_results/%1/%2.html? [R=301,L]

RewriteCond %{QUERY_STRING} page=(arithmetic|compare|test)&phpversion=(php[0-9.-]+((alpha|beta|RC)([0-9])?)?) [NC]
RewriteRule index.php /static_results/%1/%2.html? [R=301,L]

# Redirect pretty urls
RewriteRule ^(arithmetic|compare|test)/([a-z0-9_-]+)/ajax[/]?$ index.php?page=$1&tab=$2&do=ajax [QSA,NC,L]
RewriteRule ^(arithmetic|compare|test)/([a-z0-9_-]+)[/]?$ index.php?page=$1&tab=$2 [QSA,NC,L]
RewriteRule ^(arithmetic|compare|test|other-cheat-sheets|about)[/]?$ index.php?page=$1 [NC,L]

</IfModule>

On Github License

Files

Download PDF of Htaccess file
GET, QUERY_STRING, REQUEST_METHOD, static

Comments

Apache