Forum Moderators: phranque

Message Too Old, No Replies

RewriteRule causing 500 error with ¦ char

ReriteRule, ¦, char

         

gasdoc

11:16 am on Jan 13, 2010 (gmt 0)

10+ Year Member



My host setup complains about the following RewriteRule with a 500 error:
RewriteRule ^site([A-Za-z]+).xml(¦.gz) siteindex/siteindex.php?m=$1&g=$2
If I remove the (¦.gz) part the rule is accepted.
The rule is a redirect for search engines to a php script which creates multiple .xml files indexing all public pages in my elgg install. It also compresses these files into .xml.gz compressed files for extra speed and in .gz format
Can anyone assist me in resolving this issue?
Phil

jdMorgan

4:33 pm on Jan 13, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you copied that code (or copied some code for use as a "template") from this or any other forum, check to be sure that the pipe character (vertical bar) is solid, and not broken. If it is, re-type that character from your keyboard while editing the file using a plain-text editor such as Notepad.

The pipe character must be an ASCII or UTF-8 value of %7c, and not be some special UTF-16 or "high character-code" entity.

Note that it's possible that you should be using the pattern


RewriteRule ^site([a-z]+)\.(xml¦gz)$ siteindex/siteindex.php?m=$1&g=$2 [NC,L]

if your intent was to rewrite URL-paths starting with one or more letters and ending with ".xml" or ".gz".

Note the use of [NC] to make the character-comparison case-insensitive, simplifying the pattern (and doubling the code speed), and the required escaping of the literal period (it is otherwise interpreted as a regex token matching *any* single character).

Note also the addition of the [L] flag for improved efficiency. Use of [L] on every rule is recommended, unless you have a specific reason not to use it in mind.

Jim

gasdoc

7:35 pm on Jan 13, 2010 (gmt 0)

10+ Year Member



Thank you very much. It would seem that it is the pipe character that my host doesn't like. I only use a text editor for edits and the character looks solid, but I am using a USA keyboard with windows set to use a British English layout. So I have to use the windows "on-screen display" to get the pipe!
That aside, I have taken your other helpful advice and the escape \'s seem to have done the trick. That and using 2 lines (rules) to get round the pipe problem means I'm up and running. I think the code that this rule directs to requires the $ at the end oif the pattern to be omitted.

g1smd

7:50 pm on Jan 13, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



On many systems, the required 'pipe' character is obtained by using the Shift-Backslash key combination.

gasdoc

8:09 pm on Jan 13, 2010 (gmt 0)

10+ Year Member



Shift=Backslash gives me ~ and Tilde gives me ¬. Hee hee! But I definitely get a solid pipe on the screen with the "on-screen keyboard", which is found at Shift-Backslash.