如何使用.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