I have two webpage link together like when a bottom is press it leads to the second webpage. my problem is that I'm trying to get a clean url with the .php removed. now my url looks like this
http://localhost/ecommer flower shop/flowers/list.php
and the second webpage
http://localhost/ecommer flower shop/flowers/about.php.
i want my url to be like
http://localhost/ecommer flower shop/
http://localhost/ecommer flower shop/about
the code i have written for this in index.php
<?php
if ($_SERVER['REQUEST_URI'] == '/') {
# code...
return include_once './flowers/list.php';
}
if ($_SERVER['REQUEST_URI'] == '/about') {
# code...
return include_once './flowers/about.php';
}
but this is not working and gives blank page, i don't know my mistake or what to do to fix code
CodePudding user response:
Default setting of servers software search in directions index files (index.html
, index.php
). If you rebuild your catalog it can work like you want
/flowers/index.php
(/flowers
)
/flowers/about/index.php
(/flowers/about
)
/flowers/something/index.php
(flowers/something
)
CodePudding user response:
You can use Apache mod_rewrite for this.
write this in your Apache httpd.conf
file
RewriteEngine On
RewriteRule (.*)/about$ ($1)/about.php
RewriteRule (.*)/list$ ($1)/list.php
Now you can request http://localhost/flowers/list
and Apache will send that request to the file http://localhost/flowers/list.php