Latest 100 public
snipts » htaccess
showing 1-20 of 50 snipts for htaccess
-
∞ php in html via .htaccess
AddType application/x-httpd-php .php .htm .html
-
∞ Htaccess Private Files (svn, cvs, sql, etc)
# Drupal's way of denying access to delicate server files <FilesMatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl|svn-base)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template|all-wcprops|entries|format)$"> Order allow,deny </FilesMatch>
-
∞ No www
# no-www RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
-
∞ Security for WordPress
<files wp-config.php> order allow,deny deny from all </files> Options +FollowSymLinks RewriteEngine On RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR] RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR] RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) RewriteRule ^(.*)$ index.php [F,L]
-
∞ .htaccess user agent sniffing for iPhone
RewriteEngine on RewriteCond %{HTTP_USER_AGENT} iPhone RewriteCond %{REQUEST_URI} !^/_mobile/ RewriteRule .* /_mobile/ [R]
-
∞ Custom HTACCESS rules used on Komrade's Joomla! sites
########## CUSTOM RULES - START ########## # Google Apps Redirect 301 /mail http://mail.google.com/a/domain.com # Added to prevent directory browsing Options -Indexes # Redirect to WWW rewritecond %{http_host} ^domain.com [nc] rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc] ########## CUSTOM RULES - END ##########
-
∞ code added to .htaccess to enable compression of certain served content using Apache mod_deflate
# compress all text & html AddOutputFilterByType DEFLATE text/html text/plain text/xml text/x-js text/css application/x-javascript application/javascript
-
∞ WordPress 403 Error on (dv)
You were experiencing 403 forbidden errors when going to links on a WordPress blog installed on your (dv) Dedicated-Virtual Server. This can happen when there is either an incorrect .htaccess file, or no .htaccess at all. I suggest that you include a proper .htaccess for WordPress in order to clear up this issue. Below I have included the text area of a default WordPress .htaccess file. # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress Generally this issue can be attributed to how WordPress handles permalinks within the .htaccess file. If you would like to learn more about how WordPress handles permalinks, I would suggest visiting the WordPress Codex at http://codex.wordpress.org/. -
∞ htaccess redirect all traffic to homepage
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . http://domain.tld/index.php [L] </IfModule>
-
∞ mod_rewrite to fix blogger moving
RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !^/blog/images/(.*)$ [NC] RewriteCond %{REQUEST_URI} ^/blog/(.*)$ [NC] RewriteRule ^blog/(.*)$ http://blog.domain.com/$1 [R=301,L]
-
∞ Prevent .htaccess and .htpasswd file from being viewed by web clients
# # The following lines prevent .htaccess and .htpasswd files from being # viewed by Web clients. # <Files ~ "^\.ht"> Order allow,deny Deny from all </Files>
-
∞ Apache non-www .htaccess config
Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^apaair\.aero$ [NC] RewriteRule ^(.*)$ http://apaair.aero/$1 [R=301,L] # Important: It is needed to have mod_rewrite MODULE activated and have "AllowOverride Directive" set to ALL.
-
∞ better .htaccess noindex
Header set X-Robots-Tag "noindex, nofollow"
-
∞ Basic query string rewriting with mod_rewrite
<IfModule mod_rewrite.c> RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [S=40] RewriteRule ^([A-Za-z0-9\_]+)?/?$ /index.php?page=$1 [QSA,L] RewriteRule ^(events|news)/([0-9]+)/?$ /index.php?page=$1&id=$2 [L] RewriteRule ^(events|news)/([0-9]+)/([0-9]+)/([0-9]+)/?$ /index.php?page=$1&year=$2&month=$3&id=$4 [L] RewriteRule ^(events|news)/([0-9]+)/([0-9]+)/?$ /index.php?page=$1&year=$2&month=$3 [L] #RewriteRule ^([^/\.]+)/?$ /index.php?page=$1 [L] </IfModule>
-
∞ 301 redirect - non-www to www
RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com RewriteRule (.*) http://www.example.com/$1 [R=301,L]
-
∞ Cache 2nd try
# Turn on Expires and set default expires to 3 days ExpiresActive On ExpiresDefault A259200 # Set up caching on media files for 1 month <FilesMatch "\.(ico|gif|jpg|jpeg|png|flv|pdf|swf|mov|mp3|wmv|ppt)$"> ExpiresDefault A2419200 Header append Cache-Control "public" </FilesMatch>
-
∞ Cache images
<IfModule mod_expires.c> ===> btn-send.png 1 HTTP/1.1 2 Date: Sat, 25 Feb 2006 20:59:28 GMT 4 Cache-Control max-age=2592000 5 Expires: Mon, 27 Mar 2006 20:59:28 GMT 6 Last-Modified: Thu, 16 Feb 2006 12:07:03 GMT 7 ETag: "b57d55" 8 Accept-Ranges: bytes 9 Content-Length: 608 11 Connection: Keep-Alive 12 Content-Type: image/png </IfModule>
-
∞ detect iphone
.htaccess #redirect mobile browsers RewriteCond %{HTTP_USER_AGENT} ^.*iPhone.*$ RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301] RewriteCond %{HTTP_USER_AGENT} ^.*BlackBerry.*$ RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301] RewriteCond %{HTTP_USER_AGENT} ^.*Palm.*$ RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301] Javascript <script language=javascript> <!– if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) { location.replace("iphone-version.html"); } –> </script>
-
∞ Common .htaccess rules
# Google Apps redirect Redirect 301 /mail http://mail.google.com/a/domain.com # File execution order DirectoryIndex index.php index.html # Added to prevent directory browsing Options -Indexes # Redirect primary cPanel "domain.com" to a subfolder with same name: /domain.com/ RewriteEngine on RewriteCond %{HTTP_HOST} ^(www\.)?domain.com$ [NC] RewriteCond %{REQUEST_URI} !^/domain.com/ RewriteRule ^/?(.*)$ /domain.com/$1 [L]
-
∞ Compress font files for use with @font-face
# Compress font files for use with @font-face Addtype font/opentype .otf Addtype font/truetype .ttf AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css font/opentype font/truetype # Comments: Both these declarations require their appropriate modules to be active: mod_mime and mod_deflate. And for best practice, the AddType declaration should be in the mime.conf file, and the AddOutputFilterByType declaration should be in the deflate.conf file. See your particular distribution's help files for enabling and configuring Apache modules.


