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.
In .htaccess try this :
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 ; it's a Apache module that will help you with it.
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.
umm快速解决方案是创建一个名为register的目录并将其保存为index.php,然后确保所有表单都具有action="/register/"
(假设register是域的根文件夹)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.