如何使用.htaccessurl重写添加.php扩展


How to add .php extension using .htaccess url rewriting?

我在我的网站上设置了.htaccess文件,该文件在URL中显示SLUG文本作为页面名称,但没有扩展名。例如,真实url是

www.mywebsite.com/page.php?page=about-us

然后通过url重写加载到下面的url

www.mywebsite.com/about-us

下面是我的.htaccess文件代码

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !^.*(images/|'.js|'.css).*$ [NC]
RewriteRule ^([a-zA-Z0-9_-]+)$ /page.php?page=$1

现在,我想在所有页面上显示.php扩展,这样URL应该像下面一样

www.mywebsite.com/about-us.php

我该怎么做?

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !^.*(images/|'.js|'.css).*$ [NC]
RewriteRule ^([a-zA-Z0-9_-]+)'.php$ /page.php?page=$1
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}'.php -f 
RewriteRule ^(.*)$ $1.php
php_flag display_errors on