簡體   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