.htaccess htaccess重写所有页面的查询字符串

.htaccess htaccess重写所有页面的查询字符串,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我有它,它会改变查询字符串,就像下面的示例中所示: <IfModule mod_rewrite.c> #Options Allow All DirectoryIndex index.php RewriteEngine On RewriteBase /folder/ RewriteRule ^page/([^/.]+)/?$ otherpage.php?id=$1 [L] </IfModule> 如果我有这样的链接: 此htaccess将允许从以下位置访问该链接: 我

我有它,它会改变查询字符串,就像下面的示例中所示:

<IfModule mod_rewrite.c>
#Options Allow All
DirectoryIndex index.php
RewriteEngine On
RewriteBase /folder/

RewriteRule ^page/([^/.]+)/?$ otherpage.php?id=$1 [L]

</IfModule>
如果我有这样的链接:

此htaccess将允许从以下位置访问该链接:

我想要的是更改查询字符串,查找我的所有页面,但不包含任何文件夹,如:

可通过以下途径访问:

与mypage2.php和Page3.php等相同。

尝试添加此规则:

RewriteRule ^([^/.]+)/page/([0-9]+)$ /$1.php?id=$2 [L]

它几乎可以工作,但它会给出500个内部服务器错误,因为我也使用这个。如果没有这一点,您的代码可以完美地工作:RewriteCond%{REQUEST_FILENAME}上的RewriteEngine-d RewriteCond%{REQUEST_FILENAME}\.php-f RewriteRule^.*$$1.php这使得页面无需.php即可访问,我需要它。我该怎么做才能让它们一起工作?是的,你可以移除它,它不会,但我不在乎。请看下面的答案,它的评论并不需要这些。找到了另一个删除.php的解决方案,该解决方案与下面的答案配合使用