0
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /webfolder/index.php/$1 [L]

我怎样才能重定向我的网址,即

www.example.com/webfolder

example.com/webfolder/keyword

没有搞砸上面的重写?

4

1 回答 1

1

根据http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html它应该是这样的:

RewriteEngine On
RewriteCond %{HTTP_HOST} www.example.com
RewriteRule ^webfolder/(.*) http://example.com/webfolder/$1 [L,R=301]
RewriteRule ^webfolder$ http://example.com/webfolder/ [L,R=301]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /webfolder/index.php/$1 [L]

index.php 应该在,/webfolder/否则你会得到错误 500

于 2012-10-13T04:48:48.407 回答