如何使用.htaccess在地址栏中隐藏php文件名 [英] how to hide php file name in address bar using .htaccess

查看:61
本文介绍了如何使用.htaccess在地址栏中隐藏php文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

# CASE SENSITIVE METHOD

Options -Indexes 
# quick custom error "document"..
ErrorDocument 404 "<html><head><title>NO!</title></head><body><h2><tt>There is nothing here.. go away quickly!</tt></h2></body></html> 


Options +FollowSymlinks
RewriteEngine on
RedirectMatch /$ http://192.168.1.25/shrineyog/index.html

# Pass Through the empty request (to be handled as DirectoryIndex)
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /?\ HTTP
RewriteRule .? - [PT]

# If index or index.php requested, strip and redirect
RewriteCond %{THE_REQUEST} index(\.php)?
RewriteRule ^index(\.php)?$ http://www.example.com/ [R=301,L]

# Remove PHP extension from links if NOT subrequest
RewriteRule ^(.+)\.php$ $1 [R=301,NS]

# Serve PHP extension from links
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ /$1.php [L]



i使用此代码。但是它无法正常工作。请更正此代码或者给出一些其他的代码



添加了代码块格式[/ Edit]


i use this code.but its not work properly.pls correct this code or give some other code

Code block formatting added[/Edit]

推荐答案

http ://192.168.1.25/shrineyog/index.html

#传递空请求(作为DirectoryIndex处理)
RewriteCond%{THE_REQUEST} ^ [AZ] {3,9 } \ /?\ HTTP
RewriteRule。? - [PT]

#如果请求索引或index.php,请删除并重定向
RewriteCond%{THE_REQUEST}索引(\.php)?
RewriteRule ^ index(\.php)?
http://192.168.1.25/shrineyog/index.html # Pass Through the empty request (to be handled as DirectoryIndex) RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /?\ HTTP RewriteRule .? - [PT] # If index or index.php requested, strip and redirect RewriteCond %{THE_REQUEST} index(\.php)? RewriteRule ^index(\.php)?


http://www.example.com/ [R = 301,L]

#如果不是子请求,则从链接中删除PHP扩展名
RewriteRule ^(。+)\.php
http://www.example.com/ [R=301,L] # Remove PHP extension from links if NOT subrequest RewriteRule ^(.+)\.php



这篇关于如何使用.htaccess在地址栏中隐藏php文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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