mod-rewrite隐藏网址 [英] mod rewrite to hide url

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

问题描述

我想隐藏在下面的PHP文件www.example.com/~~V任何请求。

I want to hide any request on the following php file to www.example.com/.

    www.example.com/index.php  to www.example.com/     (hide index.php)
    www.example.com/content.php to www.example.com/    (hide content.php)
    www.example.com/welcome.php to www.example.com/    (hide welcome.php)

请注意:我只是想隐藏的文件,而不重定向他们。例如,隐藏的index.php或content.php部分不重定向到www.example.com/~~V。

Note: I just want to hide the file without redirecting them. For example, hide the part on index.php or content.php without redirect them to www.example.com/.

我试过

RewriteEngine On

RewriteCond %{THE_REQUEST} ^\w+\ /(.*)\.php(\?.*)?\ HTTP/
RewriteRule ^ http://%{HTTP_HOST}/%1 [R=301]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule .* $0.php

我也试过

DirectoryIndex index.php
DirectoryIndex content.php
DirectoryIndex welcome.php

这些code似乎没有工作。任何想法?对不起,我是很新的这一点。

These code didn't seem to work. Any idea? Sorry, i'm very new to this.

推荐答案

如果我没有记错这样的事情应该正常工作。

If I recall correctly something like this should work correctly.

重写规则^ / index.php的$ http://www.example.com/ [R,NC中,L]
重写规则^ / content.php $ http://www.example.com/ [R,NC,L]
重写规则^ /的welcome.php $ http://www.example.com/ [R,NC,L]

RewriteRule ^/index.php$ http://www.example.com/ [R,NC,L]
RewriteRule ^/content.php$ http://www.example.com/ [R,NC,L]
RewriteRule ^/welcome.php$ http://www.example.com/ [R,NC,L]

亲切的问候,

Kind regards,
Bo

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

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