Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Having trouble with a rewrite rule

Posted on 2011-09-08
6
Medium Priority
?
258 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
[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
  • 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 400 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
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
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

Turn your laptop into a mobile console!

The CV211 Laptop USB Console Adapter provides a direct Laptop-to-Computer connection for fast and easy remote desktop access with no software to install.

Question has a verified solution.

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

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

705 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