除去使用的.htaccess不工作。html的网址推广 [英] removing .html URL extension using .htaccess not working

查看:247
本文介绍了除去使用的.htaccess不工作。html的网址推广的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面的code删除。html的延伸形式的URL,但它不工作。

任何一个可以帮助,在这里我必须把.htaccess文件

  RewriteEngine叙述上
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{REQUEST_FILENAME} \。HTML -f
重写规则^([^ /] +)/ $ $ 1.HTML
 

解决方案

最后,我得到了正确的.htaccess code删除的.php延伸...:)

 选项+了FollowSymLinks -MultiViews
#开启mod_rewrite的上
RewriteEngine叙述上
的RewriteBase /

##隐藏PHP扩展
#要外部重定向/dir/foo.php到/ DIR /富
的RewriteCond%{THE_REQUEST} ^ [AZ] {3,} \ S([^。] +)\。PHP [NC]
重写规则^%1 [R,L,NC]

##在内部重定向/ DIR /富到/dir/foo.php
的RewriteCond%{} REQUEST_FILENAME -f .PHP
重写规则^%{REQUEST_URI}的.php [L]
 

I'm using the below code to remove .html extention form url, but it is not working..

can any one help , where i have to put the .htaccess file

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^([^/]+)/$ $1.html

解决方案

Finally I Got the correct .HTACCESS code to remove .php extention... :)

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_URI}.php [L]

这篇关于除去使用的.htaccess不工作。html的网址推广的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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