Solved

Having trouble with a rewrite rule

Posted on 2011-09-08
6
248 Views
Last Modified: 2012-05-12
I'm using a rewrite rule to parse URLS and break them down into parameters:-

]RewriteRule ^([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)$ /indexa.php?a=$1&b=$2&c=$3&d=$4&e=$5 [L] 
RewriteRule ^([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)$ /indexa.php?a=$1&b=$2&c=$3&d=$4 [L]
RewriteRule ^([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)$ /indexa.php?a=$1&b=$2&c=$3 [L]
RewriteRule ^([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)$ /indexa.php?a=$1&b=$2 [L]
RewriteRule ^([A-Za-z0-9\-]+)$ /indexa.php?a=$1 [L]
RewriteRule ^()$ /indexa.php [L]

Open in new window


This has been working fine until I try and install  a CMS add in. I put a rule in to exclude the CMS system:-

RewriteRule ^/cms/(.*)$ /cms/$1 [L]

Open in new window


In most cases such as:-

/cms/index.php
/cms/
/cms/apps/users/

The rule behaves fine. However fails to rewrite URLs to folders without the trailing / eg:-

/cms/content

I'm not A1 on regex. Am I missing something obvious here?

I can't easily change the way that these latter URLS are coded in the CMS system as it supplied to me to use.
0
Comment
Question by:cescentman
  • 3
  • 3
6 Comments
 
LVL 1

Assisted Solution

by:cescentman
cescentman earned 0 total points
ID: 36509234
Any takers?
0
 
LVL 26

Expert Comment

by:arober11
ID: 36538441
Hi, loose your CMS rule and stick the following rules in front of your original block, to bypass the logic if the URL starts with a /cms/:

# Skip the next block if the URL starts with /cms
RewriteRule /cms/?$.  -   [S=7,NC]
RewriteRule /cms/?.*  -   [S=6,NC]


Adjust the skip rule account [s=#] to suit.
0
 
LVL 26

Assisted Solution

by:arober11
arober11 earned 100 total points
ID: 36538455
Sorry typo, must remember to turn of iOS's predictive text before typing code:

# Skip the next block if the URL starts with /cms
RewriteRule /cms/?$  -   [S=7,NC]
RewriteRule /cms/.*    -   [S=6,NC]
0
Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

 
LVL 1

Accepted Solution

by:
cescentman earned 0 total points
ID: 36542961
Thanks for the help. This didn't work. Finally however I lighted on:-

RewriteRule ^cms - [L]

Which solves the problem.
0
 
LVL 1

Author Closing Comment

by:cescentman
ID: 36565425
Thanks for helping
0
 
LVL 26

Expert Comment

by:arober11
ID: 36545633
One thing i did't spot earlier I'm guessing your rules are a .htaccess file rather than the more efficient httpd.conf, as no leading / in you chosen solution.

If you are using a .htaccess file removing the leading / should get the logic to work, while permitting you to have some cms rules further down in the file.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

829 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