cescentman
asked on
Having trouble with a rewrite rule
I'm using a rewrite rule to parse URLS and break them down into parameters:-
This has been working fine until I try and install a CMS add in. I put a rule in to exclude the CMS system:-
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.
]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]
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]
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.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for helping
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.
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.
# 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.