Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Apache vhosts config RewriteCond to ignore part of URL

crmpiccocrmpicco Posts: 12Member
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:
[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][/code]
Sign In or Register to comment.