Php htaccess文件扩展名重定向规则

Php htaccess文件扩展名重定向规则,php,apache,.htaccess,Php,Apache,.htaccess,我搜索了这么多,尝试了不同的方法,但似乎都不管用: 我希望所有这些URL只转到一个页面: http://myurl.com/apply http://myurl.com/apply/ http://myurl.com/apply.html http://myurl.com/apply.php 应全部转到此处的此页面(),但URL应如下所示: http://myurl.com/apply 现在我只有重定向到.php页面的部分。我无法在隐藏.php的地方使用URL屏蔽 Redirect /ap

我搜索了这么多,尝试了不同的方法,但似乎都不管用:

我希望所有这些URL只转到一个页面:

http://myurl.com/apply
http://myurl.com/apply/
http://myurl.com/apply.html
http://myurl.com/apply.php
应全部转到此处的此页面(),但URL应如下所示:

http://myurl.com/apply

现在我只有重定向到.php页面的部分。我无法在隐藏.php的地方使用URL屏蔽

Redirect /apply http://prosaverapp.com/apply.php
Redirect /apply/ http://prosaverapp.com/apply.php
Redirect /apply.html http://prosaverapp.com/apply.php
Redirect /apply.php/ http://prosaverapp.com/apply.php
这里有一个例子

如果只想删除扩展名:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteRule ^([^\.]+)$ $1.html [NC,L]

Apache中的一些有用的操作方法:

您可以在站点根目录中使用这些规则。htaccess:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d    
RewriteCond %{THE_REQUEST} \s/+(\S+?)(?:/|\.(?:html|php))[\s?] [NC]
RewriteRule ^ /%1 [R=301,NE,L]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]