0
Hello,
I seek to customize the friendly url more this way www.portalvidapet.com.br/radium-hotel-em-guarapari
without having to pass another parameter visible in the url.
For that, I tried to do the .htaccess
as follows: RewriteRule ^/([[a-z0-9-]+)/?$ texto.php?id=$1 [NC]
, however, gives error 404.
If I do RewriteRule ^artigo/([[a-z0-9-]+)/?$ texto.php?id=$1 [NC]
works perfectly, only I wouldn’t want to use the name artigo
at the url, because, I would like to pass slug
.
To look like this www.portalvidapet.com.br/radium-hotel-em-guarapari
How to solve?
It worked very well, now I have another problem, how to capture dynamically the
id
of the news viahtaccess
? 'Cause I need this information so that pagetexto.php
give me the right result.– Gladison
If you want to access the variable you passed per parameter, just use the global scope variable $_GET['id'] to access it within the test.php page. Try printing it like this <?php echo $_GET['id']; ? > at the top of the page.
– Rafael Salomão
In this case my url will be
www.portalvidapet.com.br/radium-hotel-em-guarapari
the ideal is to search for theslug
? Or the correct is for me to pass the parameter with the urlid
plus theslug
?– Gladison
Both ways are correct. But note that if you are only going to use Slug in your database in the table where you save your posts the Slug attribute of the table has to contain a (single) Unique key so there is no duplication. If you choose to use Slug you must have a php routine so that you can access the test.php page and load the id and other necessary information through this method. But that’s the answer to another question!
– Rafael Salomão