Results 1 to 5 of 5

Thread: htaccess redirect question

  1. #1
    New user
    Join Date
    08-04-09.
    Posts
    2

    Default htaccess redirect question

    Hi,
    i have the original typolight htaccess file, but i want to add a redirect like this (the bold part):

    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .*\.html$ index.php [L]

    RewriteCond %{HTTP_HOST} ^subdomain.example.com$
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]


    But nothing seems to work, i think maybe i have to position the code lines differently, but don't no how...

    cab anyone please help?

  2. #2
    Core developer
    Official Contao Team
    leo's Avatar
    Join Date
    06-04-09.
    Location
    Wuppertal, Germany
    Posts
    201

    Default Re: htaccess redirect question

    Try it like this:

    Code:
    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{HTTP_HOST} ^subdomain.example.com$
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .*\.html$ index.php [L]
    [L] means "last rule", so in your example the custom rules have never been executed for .html documents. Now your rules are checked first.

  3. #3
    New user
    Join Date
    08-04-09.
    Posts
    2

    Default Re: htaccess redirect question

    Thanks, tried it but it doe'nt work.
    I'll just write specific 301 page for each page.

  4. #4
    New user
    Join Date
    06-25-09.
    Location
    Nova Scotia, Canada
    Posts
    26

    Default Re: htaccess redirect question

    By no means am I a mod_rewrite expert, but I wonder if the "L" at the end of both the redirect and friendly-url rules is the source of the problem. Where "L" indicates the last rule and to stop processing, as Leo said.

    Change the "L" associated with your first rewrite rule to an "N" (next rule, continue processing) and give that a whirl.

    Code:
    ...
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,N]
    ...
    Vincent Grovestine ~ Programmer/Web Analyst @ Acadia University

  5. #5
    New user
    Join Date
    07-24-09.
    Posts
    29

    Default Re: htaccess redirect question

    Quote Originally Posted by roie
    Hi,
    i have the original typolight htaccess file, but i want to add a redirect like this (the bold part):

    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .*\.html$ index.php [L]

    RewriteCond %{HTTP_HOST} ^subdomain.example.com$
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]


    But nothing seems to work, i think maybe i have to position the code lines differently, but don't no how...

    cab anyone please help?
    To redirect for canonical url purposes use this
    Code:
    RewriteCond %{HTTP_HOST} ^domain.co.uk
    RewriteRule (.*) http://www.domain.co.uk [R=301,L]
    If what you're trying to do is redirect a sub domain to your main domain then you need to create a new htaccess file in your subdomain root folder and redirect from there, hope this helps

    Nigel
    Internet Marketing is both measurable and accountable.
    On Twitter Marketing Guy
    On LinkedIn Nigel Copley
    On Facebook Caroco Marketing

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
  •