php rewrite

环境ubuntu14
apache2
php5

apt-get install php5
apt-get install libapache2-mod-php5

配置rewrite
ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load

vim /etc/apache2/apache2.conf
最后一行
ServerName ubuntu

中间
<Directory />
        #Options FollowSymLinks
        Options Indexes FollowSymLinks
        Require all denied
        AllowOverride All 
        Order allow,deny
        Allow from all
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All 
        Require all granted
        Order allow,deny
        Allow from all
</Directory>



主要是
        AllowOverride All
        Order allow,deny
        Allow from all

/etc/apache2/sites-enabled/000-default.conf
设置根路径
DocumentRoot /var/www



/var/www下
建立
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteRule "index.html" "index.php" [P,L]
RewriteRule "index.html" "index.php"
</IfModule>


apachectl restart
http://ubuntu/index.html
会跳转到index.php

猜你喜欢

转载自haoningabc.iteye.com/blog/2293300