I’ve searched high and low for a solution to this and everything I’ve tried has failed. I was looking through our server logs and noticed a number of 404s where a URL has had a variable added to the end of it (for reasons we’re still trying to understand).
A URL which should read:
www.example.com/property1/property2/
Instead reads:
www.example.com/property1/property2/http:/www.anothersite.com/ (notice the single slash after ‘http:’)
I tried using both:
RewriteRule ^/http:/www.anothersite.com/(.*)$ /$1 [L,QSA]
and RewriteRule ^/http:/$ /
but to no avail. The added complication is that the site is WordPress, so I’ve been placing new code on the line after RewriteBase /
of this code (standard to WP):
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Any assistance much appreciated! 🙂
Use the following rewrite rule
Assuming you want
www.example.com/property1/property2/http:/www.anothersite.com/
to be redirected towww.example.com/property1/property2
. Use the following to end the url with/
I’ve noticed errors like this when a mistake has been made on a webpage that I am hosting that uses a script to redirect to a specific url. The error is that the url that I am offering is invalid. Instead of “http://example.com/filename.php” it is “http:/example.com/filename.php”, which leads to it not being recognized as a url and is concatenated to the base url of the webpage. Bottom line, you need to backtrack to the referring page that has the url embedded and correct the problem that makes that url not recognized as a url. So it’s not a problem to be handled by rewritting at all because that would only treat the symptom, not the true problem. More clearly, the mistake in your example above is that the expected “http://” is “http:/” so it is not recogized as a URL and you need to fix that on the referring page.