简体   繁体   English

隐藏PHP页面的URL

[英]Hide URL of PHP page

I want to hide the URL of my PHP page; 我想隐藏我的PHP页面的URL; that is, I don't want to write /register.php directly in the href tag, I want to write /register/ and have it open the register.php page directly. 也就是说,我不想直接在href标签中编写/register.php ,而是想编写/register/并直接打开register.php页面。 I want to do that for all the webpages. 我想对所有网页都这样做。

In .htaccess try this : 在.htaccess中,尝试以下操作:

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^(.*)$ $1.php [L,QSA]

You should take a look at mod_rewrite ; 您应该看看mod_rewrite it's a Apache module that will help you with it. 这是一个Apache模块,将为您提供帮助。

Rest easy .. I am new to web development also and I had trouble making this solution work. 放松点..我也是Web开发的新手,我无法使此解决方案生效。 The detail that is not obvious is that in the php code links, you should remove the extension. 不明显的细节是在php代码链接中,您应该删除扩展名。 For example : 例如 :

<li><a href="index.php">Home</a></li> should read <li><a href="index">Home</a></li>

Then the extension goes away. 然后扩展名消失。

umm快速解决方案是创建一个名为register的目录并将其保存为index.php,然后确保所有表单都具有action="/register/" (假设register是域的根文件夹)

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

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