Solved

Having trouble with a rewrite rule

Posted on 2011-09-08
6
240 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now