簡體   English   中英

.htacces文件對我不起作用,干凈的網址

[英].htacces file doesnt work for me, clean url

我想在我的網站上看到這個localhost/articles, localhost/news

但即使我使用.htacces文件,地址到我的網站看起來像這個localhost/index.php?page=articles

我的.htacces文件:

RewriteEngine On

RewriteRule ^([a-zA-Z0-9]+)$ index.php?page=$1

RewriteRule ^([a-zA-Z0-9]+)/$ index.php?page=$1

有誰知道問題在哪里? 謝謝!

您的服務器可能正在運行apache並且禁用了mod_rewrite (當我禁用它時我得到相同的錯誤)。

嘗試添加:

RewriteCond %{THE_REQUEST} \ /+index\.php\?page=([^&\ ]+)
RewriteRule ^ /%1? [L,R=301]

此外,您的所有鏈接都需要如下所示:

<a href="/articles">

代替:

<a href="/index.php?page=articles">

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM