Results 1 to 7 of 7

Thread: .htaccess rewriterule - redirects

  1. #1
    User
    Join Date
    03-28-13.
    Location
    Bietigheim-Bissingen
    Posts
    55

    Böse .htaccess rewriterule - redirects

    After a couple of hours trying to fix this, I've decided to ask the community before I hate .htaccess.
    I have a site with several languages, the language string is in the url as first parameter. So if you go to the site, it puts the right language in the url ( www.example.com => www.example.com/en )

    I also added a RewriteRule (uncommented) to add the 'www' every time. Works in the case of the homepage (example.com => www.example.com/en) but if I access directly a sub-page, it redirects me to the home site. ( example.com/om/g.html => www.example.com/en ).

    My .htaccess file should be good, becuase if a use a .htaccess tester, I get back the correct url (example.com/om/g.html => www.example.com/om/g.html).

    So I think this problem comes from the language urls.
    My problem is I have a lot of old redirects (like: /story => /en/story.html), and these are working only when I type in the address with 'www'.

    Does anybody have an idea what could be the solution?

    Many thanks in advance!

  2. #2
    User Spooky's Avatar
    Join Date
    01-03-13.
    Posts
    339

    Default

    Post your complete .htaccess

  3. #3
    User
    Join Date
    03-28-13.
    Location
    Bietigheim-Bissingen
    Posts
    55

    Default

    Hi Spooky,
    Here you can check it out: http://www.codeshare.io/klWnJ

    Thanks!

  4. #4
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    499

    Default

    Try this
    Code:
      RewriteCond %{HTTP_HOST} ^gabor\.de$ [NC]
     #RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R=301,L]
      RewriteRule (.*) http://www.gabor.de/$1 [R=301,L]
    And try to put you redirects above line 256
    Code:
     #redirects here
      RewriteCond %{REQUEST_FILENAME} !\.(htm|php|js|css|htc|png|gif|jpe?g|ico|xml|csv|txt|swf|flv|mp4|webm|ogv|mp3|ogg|oga|eot|otf|tt[cf]|woff2?|svgz?|pdf|gz)$
    And try it first without this
    Code:
     #RewriteRule (?!tv)...
      RewriteRule ...
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

  5. #5
    User
    Join Date
    03-28-13.
    Location
    Bietigheim-Bissingen
    Posts
    55

    Default

    Hi Andreas,

    Thanks for your reaply. Unfortunately nothing changed, without www every time redirects to the home, no matter what is in the url.

  6. #6
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    499

    Default

    Can you show changed htaccess please?
    I do my rewrites this way without a leading slash on the search term
    Code:
    RewriteRule ^old /new [L,R=301]
    Try to deactivate multiviews
    Code:
    #Options -MultiViews
     Options -MultiViews
    Try to deactivate the rewrite base
    Code:
      RewriteBase /
     #RewriteBase /
    Try to do the non www to www redirect not in the htaccess, do it in your server account with a http redirect to http://www.gabor.de
    Have you filled in the domain name in the DNS field in starting point? Normaly you don't need this.
    Last edited by Andreas; 04/15/2015 at 18:50.
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

  7. #7
    User Spooky's Avatar
    Join Date
    01-03-13.
    Posts
    339

    Default

    Which Contao Version do you use currently?

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
  •