Umožňuje uživatelům určit vlastní URL stránek.
RewriteBase /
RewriteBase /test
$base_url = 'http://www.example.com';
Odstranění "index.php?q=" parametru z URL
Pokud se v odkazu vyskytují čísla, malá, velká písmena nebo pomlčka (některé řídící znaky jako je např. pomlčka je třeba v regulárních výrazech tzv. "escapovat" zpětným lomítkem), předá se systému před tímto výskytem i systémová adresa. Výskyt uzavřený v první kulaté závorce je předáván jako proměnná $1.
Zobrazovaná URL adresa: http://tomas.dankovi.info/testovaci-stranka
Systémová adresa: http://tomas.dankovi.info/index.php?q=testovaci-stranka
RewriteEngine On RewriteRule ^([0-9a-zA-Z\-]+)$ index.php?q=$1
Přepis subdomény za lomítko domény:
RewriteCond %{HTTP_HOST} ^(.*)tomas\.dankovi\.info
RewriteRule (.*) http://www.dankovi.info/tomas/$1 [L,R=301]# Redirect "universal"
RewriteCond %{HTTP_HOST} ^(.*)testpokus(.*)\.dankovi\.info
RewriteRule (.*) http://www.dankovi.info/test-pokus-%2/$1 [L,R=301]Ostranění zdvojeného www.www.:
# Redirect "remove double 'www.www.' from subdomain"
RewriteCond %{HTTP_HOST} ^www\.www\.dankovi\.info
RewriteRule (.*) http://www.dankovi.info/$1 [L,R=301]# Protect files and directories from prying eyes.
<FilesMatch "(\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)|code-style\.pl|Entries.*|Repository|Root|Tag|Template)$">
Order allow,deny
</FilesMatch>
# Set the default handler.
DirectoryIndex index.php
# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
# Enable expirations.
ExpiresActive On
# Cache all files for 2 weeks after access (A).
ExpiresDefault A1209600
# Do not cache dynamically generated pages.
ExpiresByType text/html A1
</IfModule>
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
# Site to be accessed WITH the www. only
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule .* http://www.example.com/ [L,R=301]
# Rewrite current-style URLs of the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule># Protect files and directories from prying eyes.
<FilesMatch "(\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)|code-style\.pl|Entries.*|Repository|Root|Tag|Template)$">
Order allow,deny
</FilesMatch>
# Set the default handler.
DirectoryIndex index.php
# Requires mod_expires to be enabled.
# Enable expirations.
ExpiresActive On
# Cache all files for 2 weeks after access (A).
ExpiresDefault A1209600
# Do not cache dynamically generated pages.
ExpiresByType text/html A1
# Various rewrite rules.
RewriteEngine on
# Site to be accessed WITH the www. only
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^/(.*)$ http://www.example.com/$1 [R=301,L]
# Rewrite current-style URLs of the form 'index.php?q=x'.
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule ^/(.*)$ /index.php?q=$1 [L,QSA]