Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6092409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:26:20+00:00 2026-05-23T12:26:20+00:00

I know that there is a lot of examples on Stackoverflow but I still

  • 0

I know that there is a lot of examples on Stackoverflow but I still miss something.

I’m trying to redirect http://old.domain.com/fr/ to http://brand.new-domain.com/fr/ with the following rules, but that doesn’t work:

# Enable Rewrite Engine
RewriteEngine On
RewriteBase /

# Add a trailing slash to paths without an extension
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule ^(.*)$ $1/ [L,R=301]

# Redirect domain
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^old.domain.com [OR]
RewriteCond %{HTTP_HOST} ^other-old.domain.com [NC]
RewriteRule ^(.*)$ http://brand.new-domain.com/$1 [r=301,L]

# Remove index.php
# Uses the "exclude method"
# http://expressionengine.com/wiki/Remove_index.php_From_URLs/#Exclude_List_Method
# This method seems to work best for us, you might also use the include method.
# http://expressionengine.com/wiki/Remove_index.php_From_URLs/#Include_List_Method
# Exclude root files
RewriteCond $1 !^(index\.php) [NC]
# Exclude EE folders
RewriteCond $1 !^(assets|ee-admin|images|templates|themes|fr|nl)/ [NC]
# Exclude user created folders
RewriteCond $1 !^(assets|css|img|js|swf|uploads)/ [NC]
# Exlude favico, robots, ipad icon
RewriteCond $1 !^(favicon\.ico|robots\.txt|pple-touch-icon\.png) [NC]
# Remove index.php
RewriteCond %{QUERY_STRING} !^(ACT=.*)$ [NC]
RewriteCond %{QUERY_STRING} !^(URL=.*)$ [NC]
RewriteRule ^(.*)$ /index.php?/$1 [L]

It correctly redirect when I call the root URL, but not when I call a page. What am I doing wrong?

Thanks in advance!

Pv

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:26:20+00:00Added an answer on May 23, 2026 at 12:26 pm

    When writing mod_rewrite rules, the rules get applied in the order that they appear.

    To redirect an old domain to a new domain, you’ll want that rule to be first in your .htaccess or httpd.conf file — all other rules should appear after it.

    If you only want to redirect a certain directory, the following rule will do so, while allowing the rest of the site to function normally:

    <IfModule mod_rewrite.c>
        RewriteEngine On
    
        # Redirect Only Matching Directories
        RewriteCond %{REQUEST_URI} ^/(fr|fr/.*)$
        RewriteRule ^(.*)$ http://brand.new-domain.com/fr/$1 [R=301,L]
    </IfModule>
    

    If you want to redirect the entire site, the following rule will do so:

    <IfModule mod_rewrite.c>
        RewriteEngine On
    
        # Redirect Entire Site to New Domain
        RewriteCond %{HTTP_HOST} ^old.domain.com$ [OR]
        RewriteCond %{HTTP_HOST} ^other-old.domain.com$ [NC]
        RewriteRule ^(.*)$ http://brand.new-domain.com/$1 [R=301,L]
    </IfModule>
    

    If you care about letting crawlers know your content has moved and want to make the transition as seamless as possible, be sure to keep the 301 Redirect flag in the RewriteRule.

    This will ensure that users and search engines are directed to the correct page.


    While we’re on the subject, as part of the EE 2.2 release, EllisLab now “officially” offers limited technical support for removing index.php from ExpressionEngine URLs.

    Simply add or update your code to the following, making sure to consider any rules you may already have in place:

    <IfModule mod_rewrite.c>
        RewriteEngine On
    
        # Removes index.php
        RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ /index.php/$1 [L]
    
        # If 404s, "No Input File" or every URL returns the same thing
        # make it /index.php?/$1 above (add the question mark)
    </IfModule>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.