0

我无法使用 .htaccess 重新定向我的新闻页面。我在名为 new_item.php 的文件夹 news 中显示来自 php 脚本的新闻,我得到 id= 查询字符串并查询数据库。我现在正在将我的新闻链接更改为“mysite/news/$id/news_title”我该怎么做我已经尝试使用 .htaccess 下面的代码但没有成功。

RewriteEngine On 
RewriteRule    ^news/([0-9]+)/(.*)$    ^news_item.php?id=$1   
4

1 回答 1

0

通过启用 mod_rewrite 和 .htaccess httpd.conf,然后将此代码放在您.htaccessDOCUMENT_ROOT目录下:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^news/([0-9]+)/.+$ /news/news_item.php?id=$1&lang=en [L,NC,QSA]
于 2013-07-16T18:48:32.107 回答