Answer the question
In order to leave comments, you need to log in
Need advice on creating the first page of the site
Good afternoon, everyone,
a rather noobish question has appeared, there is a small site, no CMS, only CSS / HTML inside there are some blocks in PHP, there are also not many pages, probably a maximum of 15. I would like to make it so that when clicking on links, something like site.ru/?page=price or site.ru/price is displayed .
I searched the Internet, I did not find an example understandable to my brain. I ask the community to direct me in the right direction, otherwise I feel that I am sitting inventing a bicycle.
Please don't scold me too much, I'm not a programmer at all, I've been familiar with PHP for just a couple of months.
Answer the question
In order to leave comments, you need to log in
To not rewrite anything in .htacces add
RewriteEngine on
RewriteBase /
RewriteRule ^price$ index.php?page=price
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1
I would advise you to look at the routing module of any framework, how they parse the request. For example SlimPHP, Zend Framework etc... PS Slim is small, I think it will do ;)
The easiest way to do this is:
<?php
//If is defined URL variable 'aboutme'
if(isset($_GET['aboutme'])){
// include page about me
include('include/in-aboutme.php');
//else if is defined URL variable 'interests'
}else if(isset($_GET['interests'])){
// include page interests
include('include/in-interest.php');
// in all other cases include the home page
} else {
include('include/in-home.php');
}
?>
It's called ClearUrl .
For apache, something like this (taken from somewhere from Google):
<Directory /var/www/example.com>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>
.htaccess to dig towards RewriteRule just haven't written them for a long time.
people can no longer live without frameworks for solving the simplest tasks :)
The simplest:
.htaccess index.php
RewriteEngine On
RewriteRule ^([^.]+)$ index.php
$args = explode('/',trim($_SERVER['REQUEST_URI'], '/'))
if($args[0] == 'price'){
// делаем для цены. и тд и тп.
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question