Having a problem with adding a .htaccess to one of my sites, whether I leave it blank or use code from a working .htaccess from another site I'm getting the same error 500 and my website goes down.
Could anyone point me in the right direction as to where the problem may be? Seems to be the two differences between my sites working with .htaccess and the ones not - Do you need a public_html to have a .htaccess? Or is it to do with hosting? Or something else?
I'm using ISAPI Rewrite 3 and my server is running IIS 6. I've never used ISAPI Rewrite before, so I'm a bit in the dark about how to use it.
I'm trying to do a simple redirect, so that if anyone hits
http://www.mysite.com/page.aspx
on my server, they are redirected to
http://externalsite.com/dir/file.htm
which is an external site that isn't mine. Is there a way to do this, or a tutorial that will show me how? I can't find anything on it.
There are numerous tutorials on this module. You can use these links for the beginning:
Exploding myths about mod_rewrite. Part I
Exploding myths about mod_rewrite. Part 2.
Helicon Ape - mod_rewrite documentation
ISAPI_Rewrite examples
Besides ISAPI_Rewrite, Helicon Ape and mod_rewrite are different products rewrite syntax is the same, so you can use documentation for either product.
For the redirect you are asking I guess it should be the following rule in the www.mysite.com .htaccess file:
RewriteEngine on
RewriteRule ^page.aspx http://externalsite.com/dir/file.htm [NC, R]
Hai
I want to know how to use .htaccess in my project. I know simply write the URL in to .htaccess file. After that what is the next step? what I will do to redirect the url ??
.htaccess configuration files can allow you to do lots of things -- ie, not only redirections.
For more informations, the first place you can take a look is Apache Tutorial: .htaccess files, which should give you a couple of ideas of what .htaccess files are, and when you should use them.
After that, depending on what your hosting provider allows you to do, there are several other things you might be able to do, like, for instance :
Redirections
activation/deactivation of caching
activation/deactivation of content gzipping
...
About Redictions, the basic idea is to :
define the conditions upon which redirection should occur
write down the RewriteRule that will do the redirection itself.
You'll be able to find some documentation under Apache mod_rewrite, and Apache Module mod_rewrite.
A website I maintain pro-bono was hacked, dishing out 302s to gaming sites, etc. www.rebekahshouse.org. After much searching through my hosting company's control panel, I found the culprit in the htaccess file.
It looked something like this:
RewriteEngine on
RewriteCond %{HTTP_REFERER} .oogle.com [NC,OR]
RewriteCond %{HTTP_REFERER} .ahoo.com [NC,OR]
RewriteRule .*hxxp://87.248.180.89/topic.html?s=s- [C,L]
(I think that was C, L; I overwrote it and tried to recreate it above, might've missed a piece here and there)
Anyway, I overwrote it with this:
order allow,deny
deny from all
Is this going to anything for me? What SHOULD I have in my .htaccess file? This is purely a static html site.
Thanks!
If you're running a static site its highly likely you don't need anything in your .htaccess.
You should then workout how your site actually got hacked...as if you haven't resolved that it's just going to happen again.
Your real concern should be how it happened in the first place. Defacers and such often go back and will try the same thing again on a previously cracked site, since many times the vulnerability isn't fixed.
The htaccess file is incidental. You have been hacked by one of the Russian malware gangs. If you don't close the hole that allowed the hack to happen, you will just get hacked again.
It is entirely possible that the server itself is compromised and there is more stuff on it you don't know about, such as trojan software that might not only deface your sites, but also launch attacks on others, send spam, and so on. Assuming appropriate permissions on the directory containing the htaccess file, it should not have been possible to write a file there even if you have an insecure web application on there. Certainly if you are only dealing with static files the only way such a file could have got there is by your uploading account, or the server itself being compromised.
If it's your server, as I'm guessing from the fact it responds to a direct query by IP address, you need to flatten it and reinstall from up-to-date software, use new passwords, and check your own client machines you're uploading from for infections.
(As per #YGomez's comment: first and foremost, you need to close the vulnerability which allowed the creation of that .htaccess file, else the malware will come back almost instantly; I probably should have mentioned that explicitly)
The first part will redirect all visitors coming in from yahoo and google to 87.248.180.89
The second part ("allow, deny") will deny access to your site for everybody.
I suggest to simply delete the .htaccess and be done with it - if you use a .htaccess file, you would know what goes in there, else you don't need it.
No, that won't do anything for you. For a static site you may not need a .htaccess file at all.
Step 1 : change FTP password
Step 2 : Download all files and clean
Step 3 : upload Files
Step 4 : Set 444 permission to all files, except Custom Upload folders
Remeber Do not save FTP password in your FTP client.
If you suspects that your system is infected, Format and install OS, then install a good antivirus + firewall. I suggest Avast free edition and Comodo Firewall.
We have received many inquiries and we cleaned those infected sites.
I searched for a solution of my issue and tried several ways but none of them worked.
I am migrating my website to a new system and want to change the url structure too. But I couldnt find a solution for one of them which is the most important one.
It is an e-commerce site. All product page urls had domain.com/product/productname/ in the previous system and now I need them to go to domain.com/productname.html . So the product part should be catched and redirected to the version without product/ .
Might be very simple too but I couldnt find a solution for that.
Thanks in advance
Cheers
You can use this simple rule in your site root .htaccess:
RedirectMatch 301 ^/product/([^./]+)/?$ /$1.html