当前位置: 代码迷 >> PHP >> ThinkPHP兑现URL rewrite
  详细解决方案

ThinkPHP兑现URL rewrite

热度:811   发布时间:2013-01-04 10:04:13.0
ThinkPHP实现URL rewrite
想用ThinkPHP实现URL rewrite,工程hello的目录结构如下:


http://localhost/hello/index.php/User/login,这个link是可以的。
http://localhost/hello/User/login,这个link就不可以。
http://localhost/hello/User/login

Apache httpd.conf文件的修改:
启用了LoadModule rewrite_module modules/mod_rewrite.so

<Directory />
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
修改AllowOverride为All

文件Conf/config.php的内容如下:
<?php
return array (
'URL_MODEL' => 2 
);

添加了.htaccess,内容如下:
<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>

请问应如何使http://localhost/hello/User/login可以访问?多谢!
------解决方案--------------------
<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
</FilesMatch>

有吗?

------解决方案--------------------
在Apache下只需要开启mod_rewrite模块就可以正常访问了