现在使用的是wampserver,配置了虚拟主机,按照ThinkPHP的手册中部署-URL重写的要求
- httpd.conf配置文件中加载了mod_rewrite.so模块
- AllowOverride None 将None改为 All
- 把下面的内容保存为.htaccess文件放到应用入口文件的同级目录下
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>
其中,将httpd.conf中所有的
AllowOverride None都改成了AllowOverride All,重启Apache之后还是报错Internal Server Error。
原因在与include的httpd-vhosts.conf中配置没有改成允许URL重写。
只需将
<VirtualHost *:80>
DocumentRoot "F:/wamp/www/test"
ServerName www.test.com
ServerAlias admin.tpshop.com
DirectoryIndex index.html index.htm index.php
<Directory F:/wamp/www/test>
Options FollowSymLinks
AllowOverride none
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
改成
<VirtualHost *:80>
DocumentRoot "F:/wamp/www/test"
ServerName www.test.com
ServerAlias admin.tpshop.com
DirectoryIndex index.html index.htm index.php
<Directory F:/wamp/www/test>
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
然后保存,重启wampserver就可以了。