Hide URL of PHP page

2019-04-15 03:27发布

I want to hide the URL of my PHP page; 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. I want to do that for all the webpages.

标签: php url
4条回答
甜甜的少女心
2楼-- · 2019-04-15 04:06

In .htaccess try this :

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^(.*)$ $1.php [L,QSA]
查看更多
何必那么认真
3楼-- · 2019-04-15 04:09

umm quick fix is to make a directory called register and save it as the index.php then make sure all your forms have action="/register/" (assuming register is a root folder of domain)

查看更多
Root(大扎)
4楼-- · 2019-04-15 04:16

Rest easy .. I am new to web development also and I had trouble making this solution work. The detail that is not obvious is that in the php code links, you should remove the extension. For example :

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

Then the extension goes away.

查看更多
成全新的幸福
5楼-- · 2019-04-15 04:22

You should take a look at mod_rewrite; it's a Apache module that will help you with it.

查看更多
登录 后发表回答