2017-09-03 66 views
-1

我有一个URL example.com/dashboard.php我想从URL中删除扩展名为.php,并由于您使用POST数据转换成example.com/dashboard使用htaccess的

+0

你是否也在'POST'请求​​中使用这个URL? – anubhava

+1

是的,有时我使用POST方法有时GET方法 –

+0

你的Apache版本是什么? – anubhava

回答

0

删除扩展名为.php,最好是使用308永久重定向蜜饯POST数据而不是更常用的301

RewriteEngine On 

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

## To internally redirect /dir/file to /dir/file.php 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule ^(.+?)/?$ $1.php [L] 
+0

它给我看404'http://bca.vignesh.ml/vignesh/vignesh' –

+0

这个php的网址是'http://bca.vignesh.ml/vignesh/vignesh .php'我想转换成linke这个'http://bca.vignesh.ml/vignesh/vignesh' –

+0

vignesh.php存储在dir vignesh –