Good morning, I want to create a simple URL which changes a certain URL from let's say index.php to "home", to accomplish this I wrote the code below and saved it as a .htaccess file
RewriteEngine on
RewriteRule ^home/?$ index.php [NC,L]
But all this code does is make it possible for a user to access the home page by simply typing the websites name/home but when the user follows a link the URL still shows index.php, how can I go about solving this?
You have to change the href
of the corresponding a
tags from index.php
to home
.
They are called symbolic links and is used for representation. Still the content is available via direct url.
or add the below code in your php page.
if(strpos($_SERVER['REQUEST_URI'],$_SERVER["SCRIPT_FILENAME"])===true)
header('location:home');
This will redirect people from the current page to home
if they directly visited the page
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.