本文介绍了删除扩展名的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

本地主机/ PHPExcel /文档/例子/读卡器/ exampleReader01.php

localhost/PHPExcel/Documentation/Examples/Reader/exampleReader01.php

我想删除的扩展,但是,这是不工作的上述网址

I am Trying To remove extension but this is not working for above URL

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$/Examples/Reader/ $1.php

谁能帮助我..

Can Anyone Help Me..

推荐答案

您可以在 DOCUMENT_ROOT /的.htaccess 文件中使用此code:

You can use this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On
RewriteBase /

## hide .php extension
# To externally redirect /dir/file.php to /dir/file
RewriteCond %{THE_REQUEST} \s/+(.*?/)?(?:index)?(.*?)\.php[\s?] [NC]
RewriteRule ^ /%1%2 [R=302,L,NE]

# To internally forward /dir/file to /dir/file.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
RewriteRule ^(.+?)/?$ /$1.php [L]

这篇关于删除扩展名的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 19:11