.htaccess 重写规则重定向到意外页面

.htaccess 重写规则重定向到意外页面,.htaccess,url-rewriting,.htaccess,Url Rewriting,我正试图通过以下方式通过.htaccess更改我的url Original URL: http://www.example.com/latest-news.php?id=2/topic=testing Rewritten URL:http://www.example.com/2/testing Rule for .htaccess RewriteRule ^([^/]*)/([^/]*)$ /latest-news.php?id=$1&topic=$2 [L] 这工作正常,但文件夹中存

我正试图通过以下方式通过.htaccess更改我的url

Original URL: http://www.example.com/latest-news.php?id=2/topic=testing
Rewritten URL:http://www.example.com/2/testing
Rule for .htaccess
RewriteRule ^([^/]*)/([^/]*)$ /latest-news.php?id=$1&topic=$2 [L]

这工作正常,但文件夹中存在的其他文件未打开。url以www.example.com/testing/foo.php的形式打开,但页面内容为

您可以尝试使用类似于下面的规则吗

RewriteRule ^([0-9]+)/([a-zA-Z])$ /latest-news.php?id=$1&topic=$2 [L]
无法在我的服务器上真正测试它,但您可以调整它以满足您的需要

RewriteEngine On
RewriteRule ^([0-9]+)/([^/]*)$  /latest-news.php?id=$1&url=$2 [L]

因为第二部分由字符和数字组成,所以我修改了stoica的答案。谢谢@stoica

不要单独给出答案。接受@BogdanStoica对您的帮助。谢谢。我很高兴能帮上忙!