开发者

Adding www, trailing slash to URL using Apache with clean urls

I am using an .htaccess file to send all requests to index.php like so:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase 开发者_如何学JAVA/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

I also want to have requests without www to be redirected to www.mydomain.com and most importantly add a trailing slash to all urls that don't have one. Every time I try to do this I end up with a 500 error. Anyone know how to do this?

Thanks for the help.


RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

there is also a webpage specially made for that reason: http://no-www.org/

cheers Simon

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜