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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
In .htaccess try this :
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ $1.php [L,QSA]
回答2:
You should take a look at mod_rewrite; it's a Apache module that will help you with it.
回答3:
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)
回答4:
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.