Apache .htaccess脚本阻止远程访问并允许本地ip

RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1$
RewriteRule .? http://www.example.com [L]

Apache 从浏览器地址栏隐藏.php扩展名

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

# To externally redirect /dir/foo.php to /dir/foo/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L]

# To internally redirect /dir/foo/ to /dir/foo.php
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.*?)/?$ $1.php [L]

Apache Wordpress:.htaccess性能技巧

# ########################################
# Custom HTACCESS 
# DESCRIPTION: Tips and tricks to beef up your wordpress quality
# ########################################
 
# Prevent people from browsing your WordPress folder structure
Options All -Indexes
 
# Prevent people from browsing your WordPress folder structure
<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{HTTP_USER_AGENT} !^.*(FeedBurner|FeedValidator) [NC]
 RewriteRule ^feed/?.*$ http://feeds.labnol.org/labnol [L,NC,R=301]
</IfModule>
 
# Hide your XML Sitemaps from Search Engines
<IfModule mod_rewrite.c>
 <Files sitemap.xml>
  Header set X-Robots-Tag "noindex"
 </Files>
</IfModule>

Apache 在htaccess中强制重写https和.html到.php

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]

RewriteRule ^(.*)\.htm /$1.php [R=301,L]
RewriteRule ^(.*)\.html /$1.php [R=301,L]

Apache .htacces - 干净的网址

# Follow symbolic links in this directory.
Options +FollowSymLinks

<IfModule mod_rewrite.c>
	
	RewriteEngine On
	
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule (.*) index.php?path=$1 [L,QSA]
	
</IfModule>

Apache 使用Apache添加expires头

<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/gif   “access plus 2 years”
ExpiresDefault  ”access plus 1 days”
</IfModule>

Apache 从网址中删除尾部斜杠

RewriteCond %{HTTP_HOST} ^your-domain.com$ [NC]
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]

or, if you have 'www' part in your domain name, add this instead:

RewriteCond %{HTTP_HOST} ^(www.)?your-domain\.com$ [NC]
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]

Apache HTAccess:使用简单标签重写params

RewriteEngine On

RewriteRule ^bid.wg$ index.php?pg=postbid&%{QUERY_STRING} [L]
RewriteRule ^([0-9a-zA-Z]+).wg$ index.php?pg=$1&%{QUERY_STRING} [L]

Apache WordPress .htaccess

#WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Apache TextPattern .htaccess

#TextPattern
#DirectoryIndex index.php index.html
#Options +FollowSymLinks
#Options -Indexes
<IfModule mod_rewrite.c>
	RewriteEngine On
	#RewriteBase /relative/web/path/
	RewriteCond %{REQUEST_FILENAME} -f [OR]
	RewriteCond %{REQUEST_FILENAME} -d
	RewriteRule ^(.+) - [PT,L]
	RewriteRule ^(.*) index.php
	RewriteCond %{HTTP:Authorization}  !^$
	RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>
#php_value register_globals 0