'.htaccess file redirect pages that start with the same string

I am trying to redirect two pages and i am using thw following code

RewriteRule projects/(.+) /Pages/Shop/SinglePortfolio.php?ID=$1 [NC,L]
RewriteRule projects$ /Pages/Shop/Portfolio.php [NC,L]

The first page will be like /projects/project-no-one The second will be the /projects

This rule is currenty shows the Portfolio.php page, but not the SinglePortfolio.php (404) If i revert the rules shows the SinglePortfolio.php page, but not the SinglePortfolio.php (404)

Tried

  • Without the $ at projects$
  • Other regular expressions
  • changing the projects/(.+) to project/(.+) but the prefix is the same and that seems to cause a problem.


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source