Friendly URL with PHP Oriented Obejotos [duplicate]

-2

Well I understand very little of Url Friendly , so come on, I'm developing a movie site and wanted the url to look like this:

www.site.com/página/conteúdo/temporada/episódio

instead of Page will stay (Movies, Series or Animes), Content (Movie name) and so on. Can anyone help me?

OBS: In PHP OO

    
asked by anonymous 10.05.2018 / 02:11

1 answer

1

Set the .htaccess file to something like this:

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteRule ^(filmes|series|animes)/([a-z\-]+)/([0-9]+)/([0-9]+)/?$ /index.php?tipo=$1&nome=$2&temporada=$3&episodio=$4 [NC]
</IfModule>

Pages in this format will go to the index of your site where you can get the data via get

echo $_GET["tipo"];
echo $_GET["nome"];
echo $_GET["temporada"];
echo $_GET["episodio"];

A brief explanation:

^(filmes|series|animes)/([a-z\-]+)/([0-9]+)/([0-9]+)/?$

It's a regex, the first part is a unum of options, the second takes letters and hyphen, and the other two numbers. You can change and leave more custom your way

index.php?tipo=$1&nome=$2&temporada=$3&episodio=$4 

Defines the url where the page entering the regex should be directed, passing the data to get, where each number preceded by dollar sign represents one of the previous groups

The [NC] means N or C ase, that is, case insensitive

    
10.05.2018 / 02:48