URL重写影响页面内容

时间:2016-04-14 10:30:54

标签: php .htaccess url-rewriting

我的网站具有以下文件夹结构:

website >> magazine >> news

news内,我的文件包括:

htaccess, updates.php, articles.php & article.php

所以我的htaccess看起来像是:

Options -MultiViews

DirectoryIndex updates.php

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d  

RewriteRule ^updates                        updates.php
RewriteRule ^articles                       articles.php

RewriteRule ^updates/([\w-]+)/?$            updates.php?id=$1 [NC,L,QSA]
RewriteRule ^articles/([0-9]+)/?$           articles.php?currentpage=$1 [NC,L,QSA]
RewriteRule ^article/([0-9]+)/([\w-]+)/?$   article.php?id=$1&title=$2 [NC,L,QSA]

我遇到的问题是,当我访问website.uk/magazine/news/updates/1459967836时,它会显示ID为1460544406的文章的结果。

我的updates页面中的代码是:

...
if(isset($_GET["id"])){$id = $_GET["id"];}else{
$id = "latest";
}
?>
<?php
if ($id == "latest"){$var = "ORDER BY added DESC LIMIT 1";}else{$var = "WHERE id = '$id'";}
?>
<?php
$posts_sql = "SELECT * FROM magazine_news_updates $var";
...

有人知道我访问1459967836时的原因我gewt显示1460544406的结果。

此外,当我访问website.uk/magazine/news/article-add-form.php时,即使网址显示正确,我也会看到website.uk/magazine/news/articles。任何想法?

1 个答案:

答案 0 :(得分:0)

**已解决**

删除(

RewriteRule ^updates                        updates.php
RewriteRule ^articles                       articles.php

)页面现在可以正确显示所有内容!