Strange 404 error - trying to avoid with .htaccess - .htaccess

I've got a fairly simple web site in which I trap any 404 errors and one that's started coming through is trying to access /home/sycamore/public_html/...valid url... instead of /...valid url...
Obviously /home/sycamore/public_html/ is the file path to where the site lives but firstly, how on earth is this request being generated. I can find nothing in my code that does anything like that and yet it is happening in just one area that;s been recently added. Any idea what can caused this?
In an attempt to avoid this I've added a rule to the .htaccess file so it now starts
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^/home/sycamore/public_html/(.*)$ /$1 [R,L]
However, this doesn't appear to do anything, I'm still getting the 404 reported on /home/sycamore/public_html/...valid url... although there are many other rewrite and redirect rules in .htaccess which work perfectly.
Any ideas as to (1) why the problem might be there in the first place and (2) why my htaccess attempt to 'correct' the url is failing?
I would also add that most of the requests for this URL are coming from search bots; google, yahoo, etc. and there is no mention of /home/... in the sitemap.xml file.

I'm pretty sure the original cause was down to some redirects in the htaccess file which were redirecting to a non-existent page and, I assume, causing it to generate this sort of error.
Still no idea why the attempted fix to rewrite the url didn't work but hopefully mending the htaccess file will have got rid of a lot of the problems (though there are still some unaccounted ones).

Related

QR code printed with wrong url. .htaccess redirect?

The issue is our marketing department printed the wrong QR code and the url www.batesvr.com\longcreek. Notice the . QRcode reader browser does not autocorrect the \ to a /. Is there a way in my .htaccess file to correct this issue so we don't have to reprint?
I believe it's worth trying to fix this rather than reprinting everything.
You can fix the '.' issue using the following .htaccess redirect.
RewriteEngine on
//301 Redirect
Redirect 301 /longcreek. /longcreek
Try adding this rule and check the URL. Depending on a device/browser backward-slash might be replaced with a forward-slash automatically. If not, it might be worth trying adding another redirect rule as well.
At the moment www.batesvr.com seems to be down (500 error), so if it's your real website, you might route all the traffic to the actual page. It would be a hack, but might do the trick for now.
Let me know what worked and what didn't.

HTACCESS: Redirect all the requests to another page, in place of index, hiding arguments?

I expose here my issue, I hope to explain myself clearly and correctly. In case of any specification, please ask me.
What I need is to redirect all the request (except the one to index.php) to another .php file, without the necessity to specify an argument.
here an example of what I need to do:
http://www.example.com -> shows index.php
but:
http://www.example.com/songs/title-of-the-song
should call the page: songs.php?dir=title-of-the-song of course without showin to the user the string "songs.php?dir=title-of-the-song" but just the URL
http://www.example.com/songs/title-of-the-song
It's what occurs with Drupal, but i'm not using that CMS for my site.
You are probably looking for something like that:
RewriteEngine on
RewriteRule ^/songs/(.+)$ /songs.php?dir=$1 [L]
Note: this is the version for the http host configuration. For usage in .htaccess style files you have to adapt it slightly. But if you have access to the host configuration you should always prefer that over .htaccess style files. Those files require an additional module, are notoriously error prone, hard to troubleshoot and really slow the server down.

mod_rewrite & /+Result:+chosen+nickname+%22preorrinkap%22

We've got Wordpress installed on our site and we're getting a lot of 404 pages coming up with the below at the end of them.
/+Result:+chosen+nickname+%22preorrinkap%22
The nickname at the end differs in almost all pages, but the url that preceeds the link is valid. By adding this at the end of a valid URL it makes the page come up as a 404.
As I understand it, there is a Wordpress exploit which bots (more than likely, due to the number of requests we are getting) are trying to use.
(see here https://security.stackexchange.com/questions/26598/strange-request-uri-with-lot-of-spaces-and-chosen-nickname) What I want to do is write a mod_rewrite rule to include in our .htaccess file to detect the end text and redirect the bot to the correct URL.
For example here are a couple of our links that are coming up:
/News/2010/press-releases/launch-of-ondemand-video-subscription-service/+Result:+chosen+nickname+%22preorrinkap%22
/News/2010/press-releases/launch-of-ondemand-video-subscription-service/+Result:+chosen+nickname+%22coughiscout%22
Due to the structure of our site the links will always start with /News/ if that helps.
I've tried all manner of ways of getting the regex to pickup this pattern, but i just cant get it to work.
Any help would be great.
In case someone comes across this you can set up the following redirect rule in your htaccess
RewriteRule ^(.*)\+Result:\+chosen\+nickname\+(.*)$ /News/$1 [R=301,L]
This should redirect the bot to the actual article. It turns out I wasn't escaping the plus signs correctly in my previous attempts.

.htaccess Redirect Issue , struggling with parameters

I am struggling with an url/parameter issue.
The main index.php page of my website was previously used for e.g.
www.domain.com/index.php?site=3&word=21 and
www.domain.com/index.php?site=3
But now I have changed those things, but in Google the URLs are still listed. So what I need is to redirect all the type of pages above to the main page/domain www.domain.com.
I believe .htaccess redirect is the right thing to use then, is that correct?
What type of code do I need to redirect those to main domain. Just the url's with parameters after index.php? etc. not other directories e.g. www.domain.com/sunshine/
Would be great if someone could help me with this. I believe it is actually a quick fix, but I have failed to get the code correct.
Thanks.
You can add this to an .htaccess in your site root:
RedirectMatch permanent ^/index.php* http://www.domain.com/
But, be careful if your new index page is also named index.php because you might run into a redirect loop.

magento backend url not working

I'm totally lost here, I have several Magento installations where the backend url doesn't work nice.
The problem is this:
In the frontend, all urls are perfectly rewritten so index.php is not in the url and mod_rewrite works.
but for the admin part, all urls that are created have the index.php part still in there, in a normal installation it wouldn't be a problem put now, a url like index.php/admin/dashboard results in a 404 error page. But, the funny part is that when I remove the index.php part of the url, it works.
I fixed this problem with a few .htacces tricks and hacks, but I find these hacks no good. Some parts of the backend still won't work or need their own .htacces redirect, or won't work at all even with the redirect in .htacces.
So, my questions are: Why are my Magento installations giving 404 errors on a index.php/admin call? And how to nicely get rid of the index.php part in the backend urls, without .htacces hacks?
The Magento version for all shops is 1.7.0.2
The solution is very simple, add "AcceptPathInfo On" to apache configuration.
Credits: http://www.magentocommerce.com/answers/discussion/178/index.phpinstall-was-not-found/p1

Resources