简体   繁体   English

隐藏URL的index.php(或index.html)

[英]Hide index.php (or index.html) of an URL

When I type the address of my site in a browser (mysite.com), it redirects to mysite.com/index.php. 当我在浏览器(mysite.com)中键入我的网站地址时,它会重定向到mysite.com/index.php。 Why not to index.html ? 为什么不去index.html? Because I changed it in the conf file in Apache 2.2 . 因为我在Apache 2.2的conf文件中更改了它。

  • Now I would like to hide the last "index.php" part. 现在我想隐藏最后一个“index.php”部分。 How do I do that ? 我怎么做 ?
  • Would it be different it was index.html than index.php ? 它是index.html而不是index.php吗?

Wouldn't be ugly if by looking for google, you would end up on www.google.com/index.html ? 如果通过寻找谷歌,你最终会访问www.google.com/index.html,这不会很难看吗? ... it's just for esthetics but god is it important to certain people. ......这只是为了美学,但上帝对某些人来说很重要。

I don't know why you need to use mod_rewrite. 我不知道为什么你需要使用mod_rewrite。 On my site I did nothing to hide index.php, I just don't point it anywhere in code, so instead of www.example.com/index.php?task=forum I just write www.example.com/?task=forum. 在我的网站上我没有做任何隐藏index.php,我只是不把它指向任何代码,所以我只是写www.example.com/?task而不是www.example.com/index.php?task=forum =论坛。 It works on standard apache config. 它适用于标准的apache配置。

If it's redirecting, (by sending a new Location on HTTP header, for example) then there's nothing you can do but changing the code that's doing the redirect. 如果它正在重定向(例如,通过在HTTP标头上发送新的位置),那么除了更改正在进行重定向的代码之外,您无能为力。

On the other hand, if your WebServer is Apache, there is a configuration directive that might help: 另一方面,如果您的WebServer是Apache,则有一个配置指令可能有所帮助:

DirectoryIndex 的DirectoryIndex

When you set that to: index.php or index.html , then your web server will automatically redirect to those internal files without changing the URL when you hit the directory on your server where the DirectoryIndex directive is setup. 当您将其设置为: index.phpindex.html时 ,当您点击服务器上设置DirectoryIndex指令的目录时,您的Web服务器将自动重定向到这些内部文件而不更改URL。

I guess you'll get better answers if you post this on SERVERFAULT . 如果你在SERVERFAULT上发布这个,我想你会得到更好的答案。

Good luck. 祝好运。

This seemed to work in my environment (would NOT display index.php): 这似乎适用于我的环境(不会显示index.php):

        <form action="." method="POST">
       E-mail: <input type='password' size='50' name='email' />
       <input type='submit' value='Login' />
    </form>

You can easily do this with URL mapping in either the http.conf file or individual .htaccess files in your application directories. 您可以使用http.conf文件中的URL映射或应用程序目录中的各个.htaccess文件轻松完成此操作。 Turn on mod rewrite . 打开mod重写 Here is a simple tutorial. 是一个简单的教程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM