Forum Moderators: phranque
RewriteRule ^([A-Za-z]*)([-]*)([A-Za-z]*)([-]*)([A-Za-z]*)$ /index.php?page=$1$2$3$4$5 [NC,L]
One page has two hyphens in the url, so thats why the two ([-]*).
I was looking online for a way to simplify these two, so i came up with:
RewriteRule ^(.*)$ /index.php?page=$1 [NC,L]
but this rule causes an apache server error 500. I don't get it. It looks fine to me. Can someone help me out here? Thanks.
whenever you see an apache server error 500 it's a good idea to look in the server error log for clues.
Secondly it also redirects for robots.txt and other such files. That should not happen.
.
Why simplify the rule? In many cases that makes it less efficient.
Make the rule fit exactly which URLs need to be matched, and no more.
Additionally, if a part of a URL must always be present, change the * to a + where necessary.
For example, the very first group should have a + if there are no URLs that begin with a hyphen.
If you have NC at the end, then you don't need to specify both A-Z and a-z, as the NC already says "use any case".
Do any URL parts use digits? There is no provision for that in the rules.
RewriteRule ^(([a-z]+-)+)[a-z]+)$ /index.php?page=$1 [NC,L]
If you wish, you can restrict it to match URL-paths containing only one or two character-hyphen sequences:
RewriteRule ^(([a-z]+-)[b]{1,2}[/b])[a-z]+)$ /index.php?page=$1 [NC,L]
Jim