0

I've got 2 rewriting conditions in my htaccess file.

RewriteEngine on
RewriteCond %{REQUEST_URI} ([0-9]+)/([A-Za-z0-9-]+)
RewriteRule (.*) projekt.php?id=%1&title=%2 [L]

RewriteEngine on
RewriteCond %{REQUEST_URI} ([0-9]+)/([A-Za-z0-9-]+)
RewriteRule (.*) artikel.php?id=%1&title=%2 [L]

The first one doesn't work at any time. The second one is working only if I delete the other one.. What am I doing wrong?

Thank you!

chris85
  • 23,846
  • 7
  • 34
  • 51
muzzie
  • 65
  • 8
  • 2
    How are they supposed to work in conjunction if they're identical? How should the rules know when to map project or article? – mario Nov 22 '17 at 18:31
  • What's the solution? Im not that fit with rewriting :/ – muzzie Nov 22 '17 at 18:32
  • 1
    There is no solution. This is underspecified and unanswerable as of now. – mario Nov 22 '17 at 18:34
  • How can I manage that both the first request and the second request are going to work? All i try to do is gettin /projekt.php?id=1234&title=blabla rewritten to /projekt/1234/blabla/ as well as getting /artikel.php?id=4567&title=blublu rewritten to artikel/4567/blublu – muzzie Nov 22 '17 at 20:10
  • Use the [edit] link. -- Make two distinct rules. Get rid of the `RewriteCond`s (explain where you got those from). Instead utilize the match/regex part of the `RewriteRule` for e.g. `^(\w+)/(\w+)/(\w+)$` instead of the silly `(.*)` – mario Nov 22 '17 at 22:47
  • Can you show it in my example? :/ – muzzie Nov 23 '17 at 08:41
  • Yes, I could. But I'm not going to. Admittedly this is hard to google, since everybody uses undescriptive question titles such as yours. But this might give you enough examples/pointers: https://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained – mario Nov 23 '17 at 14:28

0 Answers0