使用.htaccess重定向到文件夹而不显示索引或变量

时间:2012-02-27 07:10:02

标签: .htaccess redirect

我希望所有链接到我网站的网址都是这样的

www.sample.com?id=1234
www.sample.com/subfolder/?id=1234
www.sample.com/another_subfolder/index.php?id=1234

重定向到相应的文件夹而不显示文件或任何变量。所以上面的例子会重定向到

www.sample.com
www.sample.com/subfolder/
www.sample.com/another_subfolder/

这是我的.htaccess:

Action php53-cgi /php53.cgi
AddHandler php53-cgi .php
Options -indexes

FileETag None

<IfModule mod_rewrite.c>
    RewriteEngine On
    # Force www
    RewriteCond %{HTTP_HOST} ^sample.com$ [NC]
    RewriteRule ^(.*)$ http://www.sample.com/$1 [R=301,L]

</IfModule>

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/html "access plus 1 second"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/jpg "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType text/javascript "access plus 1 month"
    ExpiresByType application/pdf "access plus 1 month"
    ExpiresByType application/x-download "access plus 1 month"
    ExpiresByType application/x-javascript "access plus 1 month"
    ExpiresByType application/x-shockwave-flash "access plus 1 month"
</IfModule>

0 个答案:

没有答案