I want to adress to my website to look like this localhost/articles, localhost/news
but even if I use .htacces file, adresses to my site look like this localhost/index.php?page=articles
My .htacces file:
RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)$ index.php?page=$1
RewriteRule ^([a-zA-Z0-9]+)/$ index.php?page=$1
Does anyone know where the problem is? Thank you!
您的服务器可能正在运行apache并且禁用了mod_rewrite
(当我禁用它时我得到相同的错误)。
Try adding:
RewriteCond %{THE_REQUEST} \ /+index\.php\?page=([^&\ ]+)
RewriteRule ^ /%1? [L,R=301]
Additionally, all of your links need to look like:
<a href="/articles">
instead of:
<a href="/index.php?page=articles">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.