apache rewrite

piaoling  2012-08-20 00:13:07
<IfModule mod_rewrite.c>

############################################
## enable rewrites

    Options +FollowSymLinks

    RewriteEngine on

#将result?q=**重写到result/index/q/**
    RewriteCond %{REQUEST_URI} ^(.*)/result(.*)$
    RewriteCond %{QUERY_STRING} ^q=(.*)$  
    RewriteRule ^(.*)/result(.*)$ http://%{HTTP_HOST}/$1/result/index/q/%1? [R=301,L]

    RewriteCond %{THE_REQUEST} ^.*/index.php
    RewriteRule ^(.*)index.php$ http://www.domain.com/zh/$1 [R=301,L]

   

#将url结尾 / 去掉

    RewriteCond %{REQUEST_URI} ^/$ [NC]
    RewriteRule (.*) http://www.domain.com/zh/$1 [R=301,L]
    
    RewriteCond %{REQUEST_URI} ^(.*)/$
    RewriteCond %{REQUEST_URI} !(admin|key|payment)
    RewriteRule (.*)/ http://%{HTTP_HOST}/$1 [R=301,L]
############################################
## you can put here your magento root folder
## path relative to web root

    #RewriteBase /magento/

############################################
## workaround for HTTP authorization
## in CGI environment

    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

############################################
## always send 404 on missing files in these folders

    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

############################################
## never rewrite for existing files, directories and links

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l

############################################
## rewrite everything else to index.php

    RewriteRule .* index.php [L]

</IfModule>
类别 :  apache(12)  |  浏览(4211)  |  评论(0)
发表评论(评论将通过邮件发给作者):

Email: