.htaccess文件在使用apache2的Ubuntu 14.04上不起作用

.htaccess文件在使用apache2的Ubuntu 14.04上不起作用,apache,.htaccess,mod-rewrite,ubuntu,rewrite,Apache,.htaccess,Mod Rewrite,Ubuntu,Rewrite,我的.htaccess文件在使用Apache2的Ubuntu 14.04上不起作用。 这是我的档案: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?pg=$1 如何解决我的问题?根据您的信息,我只能猜测(“不起作用”不是很具体)。 很可能您没有启用mod_rewrite。输入: a2enmod重写 并在以下

我的.htaccess文件在使用Apache2的Ubuntu 14.04上不起作用。
这是我的档案:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?pg=$1

如何解决我的问题?

根据您的信息,我只能猜测(“不起作用”不是很具体)。
很可能您没有启用mod_rewrite。输入:

a2enmod重写

并在以下时间后重新启动Apache:

服务apache2重新启动

第一步 打开文件作为

sudo vim /etc/apache2/apache2.conf
第二步 如果您发现注释符号(#)位于此行之前(行号约187),请将其删除 AccessFileName.htaccess

第三步 然后在有人的地方找到那条线 选项索引跟随符号链接 不允许超限 要求所有授权

将“无”替换为“全部”

允许超越所有


.htaccess它的工作

如果它的Ubuntu LAMP是全新安装的,您可以继续执行以下步骤。这只是以上几点的总结:

第1步:

Change Directory /var/www/ from AllowOverride None to AllowOverride All

share the file permission level for .htaccess from denied to granted
Change the same settings in root@etc/apache2/sites-enabled/$ vi 000-default.conf file
如果您有Ubuntu服务器的sudo访问权限,请打开apache2.conf文件

root@etc/apache2$ vi apache2.conf
第二步:

Change Directory /var/www/ from AllowOverride None to AllowOverride All

share the file permission level for .htaccess from denied to granted
Change the same settings in root@etc/apache2/sites-enabled/$ vi 000-default.conf file
第三步:

Change Directory /var/www/ from AllowOverride None to AllowOverride All

share the file permission level for .htaccess from denied to granted
Change the same settings in root@etc/apache2/sites-enabled/$ vi 000-default.conf file
第4步:

Change Directory /var/www/ from AllowOverride None to AllowOverride All

share the file permission level for .htaccess from denied to granted
Change the same settings in root@etc/apache2/sites-enabled/$ vi 000-default.conf file
运行
a2enmod重写

这一步非常重要。它会提示您重新启动服务器

第五步: 重新启动服务器

service apache2 restart  
如果上述步骤失败,请运行

 sudo /etc/init.d/apache2 restart

如果您在apache2上使用最新版本,则需要在/etc/apache2/sites available/000-default.conf中添加以下行

您需要在此标记内添加以下内容

选项索引跟随符号链接多视图 允许超越所有 命令允许,拒绝 通融


运行“service apache2 restart”(服务apache2重启)之后,这可能会帮助其他人这是最好的答案,因为它是最全面的。我试着编辑
AllowOverride None
,但另外需要的是编辑
.htaccess
授予的权限