gargi gargi - 10 months ago 47
PHP Question

301 Redirect from old URL not working (prestashop)

I have a new site for an existing domain.

I want to redirect the old URLs to the new site, but the simple way of:
Redirect 301 oldURL newURL
isn't working.

I was told that there's a problem with the fact that the old URL contains index.php in it,
and that I need a rewrite rule for it...

example for new/old URLs:



would appreciate help with the rule I need to insert to the HTACCESS

tnx ahead



There are several ways to create a permanent redirect in .htaccess:

RedirectPermanent /index.php?type=store&category=11&subcategory=15&item=67
Redirect 301 /index.php?type=store&category=11&subcategory=15&item=67
RedirectRule /index.php?type=store&category=11&subcategory=15&item=67 [L,R=301]

Although, since you are talking about redirecting from index.php I would advise you to consider doing the redirect in code.

for examlple, you can create an oldsite_redirects.php file like this:

$redir_maps = array(
'/index.php?type=store&category=11&subcategory=15&item=67' => '/64-white-'

if(in_array(@$_SERVER['REQUEST_URI'], array_keys($redir_maps))){
header("HTTP/1.1 301 Moved Permanently"); 
header("Location: ".$redir_maps[@$_SERVER['REQUEST_URI']]);

And in the index.php file add the following line ABOVE all code and comments:


hope this helps.