KfWiki : ApacheRewrite

HomePage :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register
HomePage » WebServer » Apache » ApacheRewrite


Apache Rewrite

Just check out the examples

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


This is a stupid one requested by the client. But the QUERY_STRING part is good.
query_string
RewriteEngine On
RewriteOptions MaxRedirects=10
RewriteLogLevel 2
RewriteLog /home/sites/logs/rewrite.log

RewriteCond %{REQUEST_URI} ^/list.php
RewriteCond %{QUERY_STRING} ^cat=100011$
RewriteRule .* http://www.xxx.com/cat/whatever.html [R=301,L]

RewriteCond %{QUERY_STRING} ^cat=100011(.+)$
RewriteRule  .* http://www.xxx.com/cat/whatever.html%1 [R=301,L]


Note: depending on where you put these rewrite directives, the condition may be slight different. If you are putting them in httpd.conf, the prevailing slash is necessary
RewriteCond %{REQUEST_URI} ^/list.php


If you are putting them into .htaccess, the prevailing slash must be ignored.
RewriteCond %{REQUEST_URI} ^list.php


Multiple match in request_uri
		RewriteCond %{REQUEST_URI} ^/educators/blog
		RewriteCond %{REQUEST_URI} !^/educators/blog/index.php
		RewriteCond %{QUERY_STRING} ^(cat=|tag=|p=)
		RewriteRule .* /educators/blog/index.php [R=301,L]

There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki
Page was generated in 0.3560 seconds