子目录中单个.php页面的RewriteRule


RewriteRule for a single .php page in a sub directory

我有一个joomla网站。Recentley我在网站的根目录中添加了一个子目录,其中包含一些没有以任何方式链接到CMS的页面。

我想从这些页面的末尾删除.php,因为我要在社交媒体上推广它们,并希望URL更容易让用户记住。

有问题的页面是:

http://www.mytestwebsite.com/share/thepage.php

因此,我在.htaccess文件中添加了以下规则:

RewriteRule ^/share/thepage?$ /share/thepage.php  [NC]

希望URLhttp://www.mytestwebsite.com/share/thepage并且仍然加载page.php,但它不起作用。

使用:

RewriteEngine on 
RewriteRule ^share/thepage/?$ /share/thepage.php  [NC,L]

htaccess中的第一个RewriteRule参数中没有前导/
并且/?用于可选的尾部斜线(不是带有e?的可选e