0

In main page index.php I have two href (like menu) for objective.php and news.php
For both objectives and news I sent variables like:

<a href="objectives.php?menu=corporate-objectives">  
<a href="news.php?article=meetings">  

The idea is to load content for each page separately and to change the url's to symbolic links like:

/MyTest_proj/corporate-objectives  
/MyTest_proj/meetings  

I've tried in many ways to rewrite rules in htaccess especially to rewriterule for both pages but most of time work only for the first rewriterule for example:

RewriteRule ^([-a-zA-Z0-9]+)?$ objectives.php?menu=$1  
RewriteRule ^([-a-zA-Z0-9]+)?$ news.php?article=$1  

which obviously both page match the same paterns and the meetings was loaded in objectives.php otherwise (or in other case) I got the 401 error... The question is how do I must put and to write these rewriterules and conditions if there is any to work for both pages ?

Virgil Raica
  • 1
  • 1
  • 2

1 Answers1

0

The problem is that your RewriteRule matches any URL containing alphanumerical strings, thus matching both "corporate-objectives" and "news". Since mod_rewrite will apply the first matching rule, it never makes it to the second.

In other words, you need to make your RewriteRules more specific. Here's an example that should get you started:

RewriteRule ^([-a-zA-Z0-9]*objectives)?$ objectives.php?menu=$1  
RewriteRule ^([-a-zA-Z0-9]+)?$ news.php?article=$1  

This should mean that any URL containing the word "objectives" will load objectives.php, and anything else will load news.php.

Jenny D
  • 27,358
  • 21
  • 74
  • 110