隐藏文件名的URL [英] hide filename in url

查看:260
本文介绍了隐藏文件名的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图隐藏文件名使用以下code在.htaccess文件的URL。但文件名显示。任何人都可以解决此code。

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

解决方案

您可以使用此。在这里,我给了静态code。例如,我的文件名是testimonial.php我改变了它作为testimonial.html。因此,在一个标签链接,您应该给testimonial.php的testimonial.html代替。然后,它会正常工作。

 选项-Indexes
RewriteEngine叙述上

重写规则^ testimonial.html /testimonial.php [NC]
重写规则^ aboutus.html /about_us.php [NC]
 

I have tried hiding the filename in the URL using following code in the .htaccess file. But the File name is being displayed. Can anyone correct this code.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html

解决方案

You can use this. Here i gave the static code. for example, my file name is testimonial.php and i changed it as testimonial.html. So in the a tag link you should give testimonial.html instead of testimonial.php. Then it ll work fine.

Options -Indexes
RewriteEngine on

RewriteRule ^testimonial.html /testimonial.php [NC]
RewriteRule ^aboutus.html /about_us.php [NC]

这篇关于隐藏文件名的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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