.htaccess in my project - .htaccess

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.

Related

How to redirect old file urls using TYPO3 v9

Currently a TYPO3 website of ours has had a complete revamp and we would like to redirect all the old URL's in Googles index to the new existing URL's
For regular pages I used the new site management tool (Redirects) in TYPO3 v9. However what is left is the old indexed links of the content.
www.websitename.com/content/docs/this-is-my-document.pdf and so on. Including images and other miscellaneous links to files.
Now what would be the best way to redirect those links?
I could use htaccess ofcourse or is there something in the TYPO3 core/Extbase what I could be able to use?
I would always prefer redirects with mod_rewrite in the .htaccess file since it's much faster than any TYPO3 solution. If the redirect is done via .htaccess, there is no need for the webserver to invoke PHP or the database. Thus it's faster.
Found out we stopped rewrites by default for URL's with:
RewriteRule ^(typo3/|content/|typo3conf/|typo3temp/|uploads/|favicon\.ico) - [L]
By removing the 'content/' I was able to use the redirect functionality from the core. This was done so we could manage redirects through the TYPO3 enviroment in the future.
as Peter said above it would be faster to use .htaccess but we would like for it to be more manageable in the future through the system. So we chose the core option.

.htaccess file - Rewrite rules not working with new hosting

I have been using the following in the root of my hosting with (123-reg) for sometime now i have since moved to Godaddy and the rules not longer seem to work. I have contacted their support and they said that they follow the defaults for linux mod-rewrite rules and they believe there is a problem with my scripting...?
here is what i am using:
RewriteEngine On
RewriteRule ^fishing/$ fishing.php [L]
I have alot more rules within .htaccess but will pick this one just as an example.
When i was with 123-reg i could simply type in http://domain.com/fishing and it would load the fishing.php file.
On godaddy this goes straight to 404. Can anyone see anything obvious going on here?
For info: It works fine if i type in the full path: http://domain.com/fishing.php but this is not what i want.
Also can anyone confirm that this is a standard rewrite rule and should work with the defaults of apache mod-rewrite rules?
Turns out for some reason you have to add:
Options -Multiviews
to your .htaccess file for it to work.
Would be helpful if the techs at GoDaddy knew this information though. I have seen this on many forums on the internet about a similar problem with godaddy. Hope this helps someone else.

can htaccess prevent a file type being written to a directory?

Is it possible to get the htaccess to only allow certain files to be uploaded to a directory?
I have found several posts discussing how to get htaccess to only allow images out, disable php, output scripts in plain text form... but I cannot find if it is or is not possible to get htaccess to prevent files of a certain type from even entering the directory in the first place..
Could anyone possibly help me out on this query?
No, this is not possible. Apache is a web server, it can generally not control what gets written by a PHP or other script into a directory.
You will need to manage this in the script that you use to upload files.

.htaccess - is only for PHP?

I am working on one website which is developed in .net. I have uploaded .htaccess files but its nt working.
Is there any new idea for that? I want that my site will be crawled with www.
Thanks
.htaccess is not just for PHP.
It's a configuration file that's read by the Apache HTTP server. So if your application is not running on that server, then that file will not have any effect.
.htaccess and PHP are orthogonal. One is a configuration file for Apache; the other is a scripting language. More than likely, you're using Microsoft's IIS server, not Apache.
The .htaccess file is a configuration file for the Apache web server, and is not dependant on PHP. It typically contains settings relating to web site user permissions, friendly URL definitions, etc.
It can, however contain configuration settings for PHP, if you have settings which are in the server's PHP.ini file that you want to override for this specific web directory.
There are many reasons why a .htaccess file may not work -- it can be broken by some very subtle things, and a faulty .htaccess file will normally cause the whole site to stop working completely, regardless of what the error is.
In this case, the browser will usually simply show an error 500, without much useful information to help you debug it. But there will be more helpful debugging data in the server error log.
If you still struggle with it, you should post your .htaccess file here so we can help you debug it.
However, as #Tomalk says, if you're developing a .NET site then you're probably not using an Apache web server; you're probably using an IIS server. In that case, there are entirely different ways of setting the configuration for the server, and it won't know what to do with .htaccess file.

My site was hacked, htaccess file compromised, what should it look like?

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.

Resources