php 如何在 URL 中隐藏文件路径?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6999720/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 01:46:51  来源:igfitidea点击:

How to hide file path in URL?

phpurlfilepath

提问by Nick

What would be the best way to way to change my URL address to a custom one? Currently my website shows:

将我的 URL 地址更改为自定义地址的最佳方法是什么?目前我的网站显示:

http://nkonecny.com/_pages/_portfolio/port.html

http://nkonecny.com/_pages/_portfolio/port.html

I want to change it to something like this:

我想把它改成这样:

http://nkonecny.com/portfolio

回答by Naftali aka Neal

You can use mod_rewrites.

您可以使用 mod_rewrites。

Here is a good linux/apache tutorial

这是一个很好的 linux/apache 教程

回答by rackemup420

回答by Marc B

mod_rewrite will do rewrites of this sort, but your pages have to follow a fairly strict naming/pathing convention for it to work. If you've got arbitrary path->names, then this won't work and you'll probably have to resort to a series of Apache 'Alias' directives.

mod_rewrite 将进行此类重写,但您的页面必须遵循相当严格的命名/路径约定才能使其工作。如果您有任意的路径-> 名称,那么这将不起作用,您可能不得不求助于一系列 Apache 'Alias' 指令。

回答by psynnott

You want to use URL rewriting. If you are using apache, you can get full information here: http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

您想使用 URL 重写。如果您使用 apache,您可以在此处获得完整信息:http: //httpd.apache.org/docs/2.0/misc/rewriteguide.html