Htaccess 301重定向错误

时间:2012-10-13 04:33:47

标签: php .htaccess

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

如何重定向我的网址,即

  

www.example.com/webfolder

  

example.com/webfolder/keyword

没有搞砸了上面的重写?

1 个答案:

答案 0 :(得分: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