I am creating a dynamic web page in which certain information is loaded using a $ _GET variable. and the urls are left of the type
https://www.dominio.com/deals/deals.php?sdeal_id=483&name=nombre-producto
where the variable deal_id
is the ID of my product and with this I show the info on the page doing a mysql query, like the name, price, etc and all good in this part. The thing is that I read that using the file htaccess
I can change the url to make it more search engine friendly for an SEO topic and place it as:
https://www.dominio.com/deals/445/nombre-articulo
I have tried several regular expressions and I do not achieve the desired results since the url does not show changes and it keeps showing the same even after including the regular expression in the htaccess and probably because the changes are not implemented, I used this expression
Rewriterule ^deals/(.+)/(.+)/ deals.php?sdeal_id=$1&name=$2
and also this one.
Rewriterule ^deals/(.+)/(.+)/ /deals/deals.php?sdeal_id=$1&name=$2
The directory in which the deals.php file is located is
raiz/deals/deals.php
What am I doing wrong?
server log:
File does not exist: /home2/encorado/public_html/index, referer: https://dominio.com/deals/deals.php?sdeal_id=406&name=lavado-profundo-mantenimiento-por-hasta-4-mobil-special-minera-un-lavado-profundo-en-auto-cristales-santa-m
I use this function to redirect my url
function tep_href_link($page = '', $parameters = '', $connection = 'SSL') {
if (!tep_not_null($page)) {
die('<div><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine the page link!<div>');
}
if ($connection == 'NONSSL') {
$link = HTTP_SERVER . DIR_WS_HTTP;
}elseif ($connection == 'SSL') {
ENABLE_SSL == true;
$link=HTTP_SERVER . DIR_WS_HTTPS;
$url = "https://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
}else{
die('<div><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL</b></div>');
}
if (tep_not_null($parameters)) {
$link .= $page . '?' . tep_output_string($parameters);
$separator = '&';
} else {
$link .= $page;
$separator = '?';
}
while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);
return $link;
}
then what I did to generate my url is the following:
$nombre_oferta=urls_amigables($rsCitySubDeal['product_name']);
<a href="<?php echo tep_href_link('deals/deals.php', 'sdeal_id='.$rsCitySubDeal['product_id'].'&name='.$nombre_oferta);?>">
what generates a url of type
https://www.dominio.com/deals/deals.php?sdeal_id=483&name=nombre-producto
It should be noted that the url works because it generates the data I want.