Reputation: 993
What rule should I write for redirection in htaccess so that
http://abc.com/http://xyz.com/path/
redirects to http://xyz.com/path/
but
http://abc.com/?url=http://xyz.com/path/
should not redirect
Thanks, Loveleen
Upvotes: 2
Views: 755
Reputation: 784898
Important thing to remember for this kind of redirection is that Apache strips out all multiple slashes in RewriteRule match. For this reason it is better to use variable %{THE_REQUEST}
which remains "as is". SO just use this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(https?://[^\s]+) [NC]
RewriteRule ^ %1 [L,R]
Upvotes: 1