.htaccess重写规则错误


.htaccess rewrite rule is wrong

我正在尝试为我的网站编写.htaccess重写规则。

  1. 菜单链接必须像那样显示在地址栏中;www.abc.com/第一,www.abc.com/第二那些链接必须以page.php为根?m=第一个

  2. 新闻详细信息显示在单独的页面中www.abc.com/新闻/15,www.abc.com/新闻/98这些链接必须植根于news.php?id=15

  3. 像index.php这样的其他文件不能被重写。

我该怎么解决?

您可以使用:

RewriteEngine on 
# 3 other files like index.php mustn't be rewritten
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
# 2 
RewriteRule ^news/('d+)/?$ news.php?id=$1 [L,QSA]
# 1
RewriteRule ^(.+)/?$ page.php?m=$1 [L,QSA]