0

I am working on a website which implements Slim. All my category urls are defined in a sitemap and a page which describes all the structure with links. But I don't precise the urls of the articles in the categories of my sitemap. My webesite is on production and Google indexes al the articles. But the urls in google are like

wrong url : www.domain.com/index.php/category/blabla/article-title

instead of

good url : www.domain.com/category/blabla/article-title

In the website, when you click on a link to display an article, the url in the nacigator is the good one. It makes the wrong url only in the google index. I don't know where it comes from, could someone tell me please ? Here is the code of the url :

$app->group('/' . $ed->nomXML . '/', $handleMenu(), function () use ($app, $rubriques, $ed) {

    //display article
    $app->get($formatRubrique.'/evenements/:id/:titre', function ($id, $titre) use ($app) {
         $ctrl = new ArticleController();
         $ctrl->viewArticle($app, $id);
    });
}

and the code of .htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

1 Answer 1

0

To permanently redirect your wrong urls to good urls, you can use the following redirect in .htaccess :

RedirectMatch 301 ^/index\.php/(.+)$ /$1
Sign up to request clarification or add additional context in comments.

3 Comments

I already made a redirections, but thanks a lot, I just wanted to know where it comes from, to prevent wrong urls to be indexed. and I just saw that google actually indexed my whole website in "/stuff" AND "/index.php/stuff" (just the other urls are not at the top of the results). With the permanent redirection, will google reindex the pages with good urls and remove wrong pages or have I to make a canonical url or somthing ?
Amanite ,ofcourse google will reindex their database with new urls when they see the permanent redirect. read seo-hacker.com/301-302-redirect-affect-seo
thanks a lot ! Have you any idea of where would the bad url come from ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.