Solved

little .htaccess redirection

Posted on 2012-04-04
6
374 Views
Last Modified: 2013-12-25
is it possible to redirect automaticaly
www. website.com to www.website.com/fr
how ?
0
Comment
Question by:jerrrrry
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 21

Expert Comment

by:Papertrip
ID: 37809271
Add the following to your VirtualHost config for website.com

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?website.com$ [NC]
RewriteRule ^(/)?$ fr [R=301,L]

Open in new window

0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 37809407
The previous answer will result in an infinite loop.  It will also remove the file requested from the new URL.  Try this instead:

RewriteCond  %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !^/?fr [NC]
RewriteRule ^/?(.*)$ /fr/$1

Open in new window

0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 37809654
# "little" improved :)
RewriteCond  %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/?fr [NC]
RewriteRule ^/?(.*)$ /fr/$1 [QSA,L]

@routinet, is your REQUEST_FILENAME a typo? (it differs to REQUEST_URI in rare cases)
0
Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

 

Author Comment

by:jerrrrry
ID: 37810638
how would it work for localhost test?
thanks
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 37810682
I guess you simply can comment out

# RewriteCond  %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
0
 
LVL 51

Accepted Solution

by:
Steve Bink earned 500 total points
ID: 37814294
@ahoffmann: You are correct, sir.  That should have been %{REQUEST_URI}.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
In this article you will learn how to create a free basic website on Bitbucket, a git service provider. Polymer creates dynamic HTML components, which allow more flexibility than static HTML. This tutorial uses Ubuntu Linux but can also be done on W…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question