.htaccess重写将无法工作或被覆盖

时间:2013-10-12 22:45:50

标签: php apache .htaccess mod-rewrite

我有以下需要用.htaccess重写的网址 例如,我将使用网站的新闻栏目。

www.example.com/news/               -works
www.example.com/news/latest/        -works
www.example.com/news/1/this-is-news -does not work

这是我当前.htaccess的一部分,用于“新闻”部分。

RewriteRule ^news/? index.php?view=news [L]
RewriteRule ^news/([^/\.]+)/([0-9]+)/?$ index.php?view=news&task=$1&page=$2 [L]
RewriteRule ^news/([0-9]+)/?$ index.php?view=news&id=$1 [L]

1 个答案:

答案 0 :(得分:0)

试试这最后一个条目:

^news/([0-9]+)/[0-9a-z\-]*$

它会修复它,以便最后一个斜线中的任何数字,字母,短划线都会被捕获,所以它至少与你的例子相符。