Jump to content

need help rewriting rules


nobodyk

Recommended Posts

here's my code:

RewriteEngine on 
RewriteRule ^([^/]*)\.html$ /index.php?v=$1.jpg 
RewriteRule ^([^/]*)\.html$ /index.php?v=$1.gif 
RewriteRule ^([^/]*)\.html$ /index.php?v=$1.jpeg 
RewriteRule ^([^/]*)\.html$ /index.php?v=$1.png 

 

if I use the url http://mydomain.com/cat.html

it works because index.php?v=cat.jpg exists

but if the extension is not jpg is says the image does not exists. Shouldn't it go to the next rule instead?

 

The problem with this code is that only the first rule is read, and it never processes the other rules. Can anyone help me?

Link to comment
https://forums.phpfreaks.com/topic/197510-need-help-rewriting-rules/
Share on other sites

The rewrite engine does not know to go on, it sees that rule and it matches so it executes, albiet since you do not have the [L] I would think it would but the rewrite engine is mysterious (even apache says it).

 

I would just redirect it to index.php?v=$1  (no extension) and then do a search on index.php for v and check if file_exists if it does then yea use that extension.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.