Server removing .htaccess file. Could .gitignore be responsible? - .htaccess

I have a vps with a number of sites. One of them is having an issue where the .htaccess file is be deleted every 24hrs. I do not think it is an issue to do with the host as there are a good nuimber of similar sites with .htaccess on the same VPS.
Taking a look around I noticed a .gitignore file, unique to this site. To be honest I am not 100% sure what it does. Opening it I saw:
# ignore any files beginning with .
\.*
# except do not ignore .gitignore
!.gitignore
Could this be affecting my .htaccess file?

Turns out yes, .gitignore was responsible. I added:
# except do not ignore .gitignore
!.gitignore
!.htaccess

Related

gitignore the all files in directory except one

I want to disable everything in directory sessions/ except of the file .htaccess that disable indexes of the directory, I have this in my .gitignore:
sessions/*
but this also ignore .htaccess file that inside sessions.
you can add exceptions with exclamation mark:
sessions/*
!sessions/.htaccess

which are the valid .htaccess directories

Is there any need for .htaccess files in directories higher than that where index.html is placed?
I found such a file one level higher after a FileZilla accident (my fault; not Filezilla's) and suspect it should be deleted.
The .htaccess file has an effect on the directory it's in and all the descendent directories. You would need another .htaccess in a sub-folder if it was altering rules or adding new ones to what was inherited from its parent directory.
To expand on this based on more info from below: If the .htaccess files are in directories above your hosting dir, they will have an effect. However you should not amend or delete files on shared servers that you don't have direct authorization to. Check with your host or sysadmin - maybe those files need to be there, or perhaps they can be tidied up. In any case you can override .htaccess rules with a .htaccess file in the subdirectory.

My .htaccess files "Save As" .htaccess.htaccess. Is that normal?Does it effect my PHP in codeigniter?

This occurs in Sublime Text 2 and Wordpad, Notepad. I have been fighting to remove index.php from my URLs and I wondered if this might be the problem, I'm new. Thanks.
Yes, it will affect your codeigniter setup - your mod_rewrite rules won't be picked up unless the file is called .htaccess, and so the index.php won't be removed like you want it to.
I would fix this by going into a terminal/command prompt, go to the directory where the .htaccess.htaccess file is and renaming the file there.
If you are using windows, you do this with the command (once you are in the correct directory)
rename .htaccess.htaccess .htaccess

How to change base_url in drupal 7, fail to find answer online

I am trying to change base_url on my drupal 7 website, but failed to do it and google a lot, still could not solve it .
I am running localhost/drupal "on my local server. but I want to run it like
" localhost ". ( sorry I have to get rid of http://, otherwise it doesnot let me post)
How to get rid of folder in the url. I know I need to change $base_url on sites/default/setting.php to
$base_url = 'localhost'; // NO trailing slash! ( sorry I have to get rid of http://, otherwise it doesnot let me post)
And in the .htaccess file I am so confused what should I change. People online have their own solution, some said they work , some could not . Could someone give me some suggesttion ?
I assume this has to do with where you have placed your files.
In your file system, remove the 'drupal' directory and place all the files within that at /var/www/html ... instead of /var/www/html/drupal, if that's how it is currently set up.
I feel your pain; I've had this trouble myself before and I believe I had to alter both the settings.php and the htaccess (but try one at a time to begin with). I'm fairly sure that the section below in your .htaccess is what needs changing (just remove the hash from in front of the RewriteBase line). If you're unsure of what you're doing, make a copy of your .htaccess as htaccess.txt and then you can always switch back over if things get nasty.
# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
# RewriteBase /drupal
I just realised that what you need is a re-write rule in an .htaccess file within your root folder (not the one that's inside the drupal folder). First, undo any edits you've already made, then create an .htaccess file in the same folder that contains your drupal folder and in it, add:
RewriteEngine On
RewriteRule ^$ /drupal [L]
That should send any traffic from the root into the drupal file structure. If you get issues with strange css, or urls that include the /drupal path, you'll need to revisit the other options in the /drupal/.htaccess file and your settings.php file in order to get it all working correctly.
However, going down this route, you may as well just copy all the files and folders into the root directory anyway (as the first answer suggested), assuming you're not going to be running multiple sites. If you do want to be testing multiple sites, you can just change the RewriteRul above to whatever site directory you're wanting to test in future.

Make php.ini file recursive on 1and1 hosting

I have my website hosted on 1and1 servers and I want to adjust some settings in a php.ini file. I can create the file and it is being interpreted correctly but only for the immediate directory not for any subdirectories. I would like to not have to copy the php.ini file into every single subdirectory. The only way I have seen to do this from googling is to add the following to the .htaccess file
suPHP_ConfigPath /path/to/htdocs/php.ini
I have an .htaccess file and the different directives I have in there are being interpreted correctly but when I add that line it causes a 500 Internal Server error.
Can anyone suggest what I can do so that the php.ini settings are used in all the subdirectories without having to duplicate the php.ini file into all the subdirectories?
You could create soft links in each folder to your main php.ini. 1and1 disallows many directives in their .htaccess files. 1and1's support site has more information.
The suPHP is evaluated in a .htaccess PerDir context. If you want to have different ini files for different directories then you need to use a separate .htaccess in each relevant directory. By default Apache will use the lowest .htaccess on the request URI's path that it can find. Alternatively if you have a systematic naming convention for the filenames, then you ban place the different suPHP directives in different directives.

Resources