3 apache ubuntu .htaccess mod-rewrite rewrite
我的.htaccess文件在我的带有Apache 2的Ubuntu 14.04上不起作用.
这是我的文件:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?pg=$1
Run Code Online (Sandbox Code Playgroud)
我如何解决我的问题?
Hor*_*ren 12
根据您的信息,我只能猜测("不起作用"并不是非常具体).
很可能你没有启用mod_rewrite.输入:
a2enmod rewrite
然后重启Apache:
service apache2 restart
小智 9
第一步打开文件为
sudo vim /etc/apache2/apache2.conf
Run Code Online (Sandbox Code Playgroud)
第二步删除注释符号(#)如果在此行之前找到它(行号187约)AccessFileName .htaccess
第三步然后找到有选项索引的行FollowSymLinks AllowOverride无需要全部授予
用"全部"替换"无"
AllowOverride All
.htaccess它的作品!!
如果是全新安装的 Ubuntu LAMP,您可以按照以下步骤进行操作。只是以上几点的总结:
第1步:
如果您对 Ubuntu 服务器有 sudo 访问权限,请打开 apache2.conf 文件
root@etc/apache2$ vi apache2.conf
Run Code Online (Sandbox Code Playgroud)
第2步:
Change Directory /var/www/ from AllowOverride None to AllowOverride All
share the file permission level for .htaccess from denied to granted
Run Code Online (Sandbox Code Playgroud)
第 3 步:
Change the same settings in root@etc/apache2/sites-enabled/$ vi 000-default.conf file
Run Code Online (Sandbox Code Playgroud)
第四步:
跑 a2enmod rewrite
这一步真的很重要。它会提示您重新启动服务器。
第五步: 重启服务器
service apache2 restart
Run Code Online (Sandbox Code Playgroud)
如果上述步骤失败运行
sudo /etc/init.d/apache2 restart
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10110 次 |
| 最近记录: |