Forum Moderators: phranque

Message Too Old, No Replies

Any help would be appreciated

         

Databasesdoneright

11:20 pm on Feb 18, 2008 (gmt 0)

10+ Year Member



I am trying to redirect urls such as:

[127.0.0.1...]
to
[127.0.0.1...]

I was having trouble getting the non greedy operator to work and stumbled upon the code below which works on my computer but does not work on the native server.

Code:
RewriteEngine on
RewriteBase /

RewriteRule ^Magic-The-Gathering/([^\.]*?)-Card-List\.html$ index.php?page=Cards&edition=$1

Could someone please help me to get this rewrite to work. I suspect it is something simple but it has continued to elude me.

Thanks!

jdMorgan

12:50 am on Feb 19, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Regex support in mod_rewrite is limited, and does not include all of the options provided by PERL, PHP, and other scripting languages. Support for "minimal greediness" and "atomic back-references" is not universally available, and internal pattern recursion isn't supported at all, AFAIK. For maximum portability, use only the tokens, operators, and quantifiers shown in the mod_rewrite documentation.

Since you're trying to grab everything in the "first-level subdirectory" up to the "-Card-List," you need to be looking for "not a slash" rather than "not a period." To avoid using the non-greedy "*?" extended-regex quantifier, you could use:


RewriteRule ^Magic-The-Gathering/([^/]+)-Card-List\.html$ index.php?page=Cards&edition=$1

The regex processor *is* going to have to go through multiple "back-off-and-retry" cycles to get a match.

Be aware that the processing of regular expressions depends on the particular POSIX library bundled with the operating system, and not upon the Apache version.

Jim

Databasesdoneright

2:58 pm on Feb 19, 2008 (gmt 0)

10+ Year Member



Thanks for the help!