.htaccess, mod_rewrite, and Trailing Periods in URL

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
ex272
Forum Newbie
Posts: 1
Joined: Mon Jul 21, 2008 7:44 pm

.htaccess, mod_rewrite, and Trailing Periods in URL

Post by ex272 »

Hi,

I'm trying to accomplish something similar to the following, where everything after the domain name would parse into a php GET.

http://en.wikipedia.org/wiki/A.W.O.L.

However I'm having trouble preserving trailing periods using rewrite. Unless there is some content after the period, the htaccess simply truncates the url to the last "normal" character (i.e. letter, number, etc.). In the case of the example above, what my GET would get is "wiki/A.W.O.L" (notice there is no longer a period after the "L").

These parameters must match exactly against a database of authors and titles, many of which are enclosed by periods and other punctuation marks. So this behavior certainly wouldn't work for me. This doesn't happen when I simply pass the string directly to index.php?a="..." -- only when using the mod_rewrite. I tried playing around with regex, but haven't been able to figure it out. How did the guys at Wikipedia do it?

Here's the cruddy code I currently have in my htaccess file:

Code: Select all

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?a=$1 [L]
Thanks for any advice.
Post Reply