您的位置:首页 > 运维架构 > Apache

Ubuntu Apache 开启加载Rewrite 伪静态

2016-06-16 17:46 465 查看
    开启加载Rewrite

执行下命令加载

a2enmod rewrite


然后建立软连接

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


编辑apache2.conf文件

sudo vi /etc/apache2/apache2.conf

找到 AllowOverride None 改成ALL

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride ALL
Require all granted
</Directory>

重启Apache 

/etc/init.d/apache2 restart


在网站根目录新建.htaccess文件,没有文件名,内容为以下内容。如果新建不了就下载附件。

AddDefaultCharset utf-8

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息