ubuntu:
sudo a2enmod rewrite
安装apache模块 然后重启apache
sudo service apache2 restart
查看phpinfo()中是否加载了mod_rewirte模块
然后进入/etc/apache2/apache2.conf
将里面的AllowOverride None都改为AllowOverride All,重启apache
然后在需要重写url的文件夹下建立.htaccess,这个是隐藏index.php文件的
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php [NC]
RewriteRule ^ %1 [R=301,L]