的.htaccess重写的.php为“虚拟文件夹” [英] .htaccess Rewrite .php to 'virtual folder'

查看:438
本文介绍了的.htaccess重写的.php为“虚拟文件夹”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  

可能重复:
  删除扩展名为.php用的.htaccess

  http://www.example.com/test/categoryform.php
 

在我的.htaccess文件,我怎么重写显示为:

  http://www.example.com/test/categoryform/
 

解决方案

试试这个code OUT

  RewriteEngine叙述上
#开启mod_rewrite的引擎

的RewriteCond%{} REQUEST_FILENAME -f .PHP
#如果请求的文件名与PHP扩展是存在的文件,
的RewriteCond%{REQUEST_URI}!/ $
#与该请求不是一个目录
重写规则(。*)$ 1 \ .PHP [L]
#重定向到PHP脚本与被请求的文件名
 

隐藏PHP扩展 - htaccess的问题也是有用的。

Possible Duplicate:
remove .php extension with .htaccess

I have

http://www.example.com/test/categoryform.php

In my .htaccess file, how do I rewrite that to display as:

http://www.example.com/test/categoryform/

解决方案

try this code out

RewriteEngine On
# turn on the mod_rewrite engine

RewriteCond %{REQUEST_FILENAME}.php -f
# IF the request filename with .php extension is a file which exists
RewriteCond %{REQUEST_URI} !/$
# AND the request is not for a directory
RewriteRule (.*) $1\.php [L]
# redirect to the php script with the requested filename

and hide .php extension - htaccess question is also usefull

这篇关于的.htaccess重写的.php为“虚拟文件夹”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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