Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-24-2012, 02:25 PM   PM User | #1
crmpicco
Senior Coder

 
crmpicco's Avatar
 
Join Date: Jan 2005
Location: Mauchline, Scotland
Posts: 1,091
Thanks: 15
Thanked 1 Time in 1 Post
crmpicco has a little shameless behaviour in the past
Apache vhosts config RewriteCond to ignore part of URL

I am attempting to control redirections on my site using the Apache vhosts config.

I have two-letter regions setup, such as /fr, /de, /es, which I am currently ignoring as you will see from my vhosts file below. However I also have a 301 permanent redirect setup to redirect /cm (and /fr/cm, /es/cm etc) to another page - this is controlled in my back-end system.

The complication is when I add the line RewriteCond %{REQUEST_URI} !^/cm this is caught by the RewriteCond, however I then cannot access /fr, /de, /es etc at all as they seem to get stuck in a loop and go to: www.ayrshireminis.com/fr/fr/fr/fr/fr/fr/fr/fr and then it HTTP 500 Internal Server Errors.

How could I change the RewriteCond to allow for:

/pa (this will be redirected to /minis, but it is controlled in the database and needs to stay as a valid URL)
/fr (the region)
/fr/pa
/es/pa

etc.

Code:
    # ----------------------------------------------------------------------
    # REGION SPECIFIC REDIRECTIONS
    # Below will remove region specific part of URL and load content from main UK site
    # ----------------------------------------------------------------------
    RewriteCond             %{REQUEST_URI}                  ^/([a-z]{2})$                   [OR]
    RewriteCond             %{REQUEST_URI}                  ^/([a-z]{2}/)(.*)$
    RewriteCond             %{REQUEST_URI}                  !^/cm
    RewriteRule             ^([a-z]{2}/|[a-z]{2})(.*)$      /$2                                             [L,QSA]

    # For VirtualDocumentRoot development instance configurations
    RewriteRule ^([^.]+)$ /index.php?url=$1 [L,QSA]
crmpicco is offline   Reply With Quote
Reply

Bookmarks

Tags
apache

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:53 AM.


Advertisement
Log in to turn off these ads.