Results 1 to 4 of 4

Thread: redirect old addresses with index.php, to the new structure

  1. #1
    New user
    Join Date
    05-24-12.
    Posts
    8

    Default redirect old addresses with index.php, to the new structure

    Hello,

    I'm French and I come to the community contao.org, because I can not find a solution to my problem.

    Let me explain:

    I am trying to make the activation of url-rewriting a website already online. Here is the code that I use and that works perfectly:

    Code:
    AddType x-mapp-php5 .php
    
    DirectoryIndex index.php
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^.*\.html$ index.php [L]
    RewriteCond %{HTTP_HOST} ^website.com [NC]
    RewriteCond %{HTTP_HOST} !^www.website.com [NC]
    RewriteRule ^(.*)$ http://www.website.com/$1 [L,R=301]
    ErrorDocument 404 /error-404.html
    Now, if a visitor comes to the site via website.com, it will automatically be redirected to http://www.website.com. In addition, the index.php (in website.com/index.php/name-page.html) is automatically deleted.

    And therein lies the trouble, because if a visitor arrives via the old URL, eg:

    website.com/index.php/services.html there be a 404 because the new address is http://www.website.com/services.html

    Clearly, how to make the old URLs (with /index.php/) redirect to the new address?

    Thank you in advance for your solutions!

  2. #2
    New user
    Join Date
    05-24-12.
    Posts
    8

    Default Re: redirect old addresses with index.php, to the new struct

    Hello,

    I found a solution that works ... addresses http://website.com/index.php/services.html are automatically referred to http://www.website.com/services.html !

    I leave it .htaccess like this, the time reference Google again ... new URL I will return later to something "more traditional".

    Code:
    AddType x-mapp-php5 .php
    
    DirectoryIndex index.php
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*).html / [L]
    RewriteCond %{HTTP_HOST} site.com [NC]
    RewriteCond %{HTTP_HOST} !^www.site.com [NC]
    RewriteRule (.*) http://www.site.com/$1 [L,R=301]
    RedirectMatch permanent /index.php/(.*).html http://www.site.com/$1.html
    ErrorDocument 404 /error-404.html
    ErrorDocument 403 /error-403.html
    What do you think the code ?

    PS: I do not know why, but I had to replace the "^ (. *) $" With "(. *)" ... because it produced errors. An explanation ?

  3. #3
    User
    Join Date
    06-19-09.
    Posts
    328

    Default Re: redirect old addresses with index.php, to the new struct

    you need to add the querystring to the rewrote url
    Consulenza Contao CMS https://www.intco.it

  4. #4
    User
    Join Date
    07-06-09.
    Posts
    44

    Default Re: redirect old addresses with index.php, to the new struct

    Did you solve the issue? I am having exactly the same problems. I'd be glad if you did find a solution for this...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •