I have this in my .htaccess:
RewriteEngine On
RewriteBase /
RewriteRule ^url/(.*)$ url.php?url=$1 [L]
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]
Why does http://mydomain.ext/url/http://www.google.com/ not match the first rule, but the second???
Edit: it seems to work when I comment out the last line, but of course i cannot do that. What’s going on?
Edit2: If i change it to this it works:
RewriteEngine On
RewriteBase /
RewriteRule ^url/(.*)$ url.php?url=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]
Can anyone explain why the previous version didn’t work as expected?
The request is probably getting rewritten twice:
/url/http://…→/url.php→/index.php. Exclude that path from the second rule and it should work: