删除文件扩展名htaccess的不工作 [英] remove file extension htaccess not working

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

问题描述

以下code工作不删除文件扩展名的.php

the following code is not working to remove the file extension .php

Options +FollowSymLinks
RewriteEngine On

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

我的网址无法从例如/ about.php 更改为 example.com/about

推荐答案

我已经找到了答案。其工作。在code是如下重写和重定向的URL

I have found the answer. Its working. the code is as follows to rewrite and redirect the url

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]

## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_FILENAME}.php [L]

据重写并重定向的URL。感谢所有为乌拉圭回合的答案。

It rewrites and redirects the URL. Thanks all for ur answers.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆