繁体   English   中英

.htaccess在Windows上工作,但是在ubuntu中的apache2上不工作

[英].htaccess working on windows however not working on apache2 in ubuntu

我在Windows的XAMPP中使用以下htaccess代码,效果很好。 但是,相同的代码在Ubuntu Apache2上不起作用,

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ /?cmd=$1&caseSno=$2 [NC,L]
RewriteRule ^([^/\.]+)/?$ /?cmd=$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/?$ /?cmd=$1 [NC,L]

没有.htaccess文件,我正在使用我的网站链接,如下所示:

http://localhost/index.php?cmd=home

哪个工作正常。

但是在将.htaccess文件用作上述代码后,我将链接更改为:

http://localhost/home

但是在ubuntu中,这些规则不起作用。 任何帮助将不胜感激。

您可以执行以下操作:[在终端上编写以下命令]

sudo nano /etc/apache2/apache2.conf

Check your file if there  is any # sign before the 

AccessFilename .htaccess

删除#号。

转到以下并将“ 无”更改为“ 全部”

<directory /var/www/> 
   Options Indexes FollowSysLinks
   AllowOeverride None
   Require all granted
</directory>

更换

**AllowOverride None** to **AllowOverride All"

这就是您所做的全部。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM