-1

A php script to generate virtual pages based on keyword array, is using a template master file. This is it's rule:

RewriteRule ^([+a-zA-Z0-9]+)/([+a-zA-Z0-9]+)\_service.html$ /master-one.php?city=$1 [L]

I want to add another master file to be read based on the secondary keyword array. Tried copying the rule, changes /master-one.php to /master=two.php, But this results in pages being generated by keyword, but displays master-one.php content.

How do I solve this riddle?

jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252
eddie
  • 19
  • 4
  • 1
    Like you've been told last time, you need to have a differentiating factor for both URL mappings. The RewriteRule (and neither we) can guess which of your "master files" (which is the very part that would need elaboration) handles which keywords. – mario May 30 '15 at 18:27
  • 1
    Instead of making it harder on me why dont you try and help me. I dont understand what am I doing wrong here. This is not a why to treat a disabled man. – eddie May 31 '15 at 08:24
  • Eddie , do you have 2 rules in your htaccess? – Amit Verma May 31 '15 at 09:48
  • 1
    @eddie As I recall, I did try to help. But you seem to have deleted the question where I put those comments... – jeroen May 31 '15 at 14:25
  • Thanks for your help @Starkeen, no I have only this one. – eddie Jun 01 '15 at 08:23

1 Answers1

0

Sure. You can have more than one RewriteRule. They just need to have different patterns and should be ordered by desired priority.

Simply avoid overly generic placeholders. It might just look like:

RewriteRule ^(Boston|Washington|Whatever)/(\w+?)_service.html$ /one.php?c=$1 [L]
RewriteRule ^(Paris|London|Amsterdam)/(\w+?)_service.html$     /two.php?c=$1 [L]
RewriteRule ^(\w+)/(Else|And|Whatever)_service.html$        /else.php?xyz=$2 [L]

The \w+? matches alphanumeric characters. The alternative lists (X|Y|Z) are whatever keywords each rule should match.

Neither rule can look up what keywords each of those template/master files can handle. You'll therefore have to manually craft your alternative lists. (There are automatisms for that [RewriteMap], but that's impossible to answer without any further details - that you've been asked for...)

See also: Reference: mod_rewrite, URL rewriting and "pretty links" explained

Community
  • 1
  • 1
mario
  • 144,265
  • 20
  • 237
  • 291
  • Thanks for your help @mario, I tried this but it gives 404 error page, of course I changes everything relevant but still gives an error. I wish I could explain more so it will be more clearer. – eddie Jun 01 '15 at 08:28
  • If I would to paste some of the script code, will this help ? – eddie Jun 02 '15 at 17:21
  • No, it wouldn't. I'd guess you likely didn't even write those scripts. Else you could have summarized or explained their behaviour. Two days ago. – mario Jun 02 '15 at 18:24