I'm trying to include .htaccess inside httpd.conf for better performance.
I am following the instructions from the readme file here to improve site performance. I took the .htaccess and placed it in my website root folder C:/xampp/htdocs/apps then inside httpd.conf I've got the code below. then I restarted apache. The problem is i don't think the .htaccess rules are being applied
Is this the correct way of including .htaccess and am I including it in the correct directory?
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
Include C:\xampp\htdocs\apps\.htaccess
</Directory>
If you want to "include" the contents manually in directory context with the Include directive, set AllowOverride to none, otherwise you are applying the same configuration twice, once in directory and another through AllowOverride method.
If you just want to have a .htaccess file (wouldn't figure why because you seem to have access to the main configuration), then AllowOverride all would be enough.
If you just want to .htaccess and make sure it is being applied you can just:
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
and add junk text in the .htaccess file inside this directory, if it is being read, Apache will responde with a 500 error, if it is not, chances are you are landing in another virtualhost where this directory is not set.
AllowOverride All
should already tell apache to let .htaccess override all settings. There is no need to include it manually i think.
Related
I'm running an Apache server on my computer through MAMP, and I can't seem to get it to read my .htaccess file. All of the solutions I've looked at have said to make sure that my AllowOverride is set to All in httpd.conf, which it is, but this doesn't seem to resolve my issue. I know that .htaccess isn't being read since I've written some nonsense at the start of the file and no error is being produced. I have also restarted the Apache servers after changing httpd.conf. Maybe the problem is that I'm not completely sure where I'm supposed to place the .htaccess file.
My MAMP document root was formerly MAMP > htdocs, but I changed it to Library > WebServer > Documents, which is where all of my PHP files are located. The current project I'm working on is a subdirectory of this, say Library > WebServer > Documents > project. This is the folder that contains my .htaccess file. My httpd.conf file is in MAMP > conf > apache, and the relevant section of it is as follows:
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
Do I need to change the directory from / to something else to get this working? Any help is really appreciated.
Edit: I added the following <VirtualHost> block to my httpd.conf following the comments below, but again, nothing seems to change:
<VirtualHost *:80>
ServerAdmin email#site.com
ServerName localhost:8890
DocumentRoot /
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Update (Solved): I was able to resolve the issue by reverting MAMP's DocumentRoot to its original MAMP > htdocs as opposed to my Library > WebServer > Documents. Apache is now reading the .htaccess file located in my MAMP > htdocs > project. Thanks everyone for the help.
First I would try to fix my VirtualHost to use the correct paths. I'm not super familiar with Mac, but if Library > WebServer > Documents > project corresponds to /Library/WebServer/Documents/project in your file system, then I would use that. Might be /home/your_username/Library/WebServer/Documents/project but as I said, I'm not a Mac guy. Next, I don't understand why you have directives for the same directory with opposite permissions, so I would try to remove the first Directory block or change the targetted directory to something else on one of the blocks. Note that you should never grant access to / with apache as it would be a very big security breach.
<VirtualHost *:80>
ServerAdmin email#site.com
ServerName localhost:8890
DocumentRoot /Library/WebServer/Documents/project
<Directory />
AllowOverride none
Require all denied
</Directory>
<Directory /Library/WebServer/Documents/project>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
If it still doesn't work, you might want to make sure that the filename Apache is looking for hasn't been changed to something else using the AccessFileName directive.
Also, you are not giving details on where you put the VirtualHost block, but if it is in a separate file. Make sure you are including that file somehow.
You don't specify your Apache version but since version 2.4, you should Require instead of Allow directives since this is deprecated. See https://httpd.apache.org/docs/2.4/en/howto/access.html
Try adding Listen 80 and Listen 443 to the top of the main config.
Check your httpd.conf. Via the AllowOverride (http://httpd.apache.org/docs/current/mod/core.html#allowoverride) and AllowOverrideList (http://httpd.apache.org/docs/current/mod/core.html#allowoverridelist) directives it can control whether or not .htaccess files are considered.
When this directive (i.e. AllowOverride) is set to None and AllowOverrideList is set to None, .htaccess files are completely ignored. In this case, the server will not even attempt to read .htaccess files in the filesystem.
Please note that the default value is None for both, which cause exactly this behavior of not considering .htaccess files.
in my apache sites-available/default file i had change the config to folowing:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All //originally was AllowOverride None
FallbackResource rewrite.php //i added this line, too
Order allow,deny
allow from all
</Directory>
i wanted to handle all url calls in my own rewrite.php file. this works, when i visit my site at http://192.168.1.104:4567/web/knxzkcha but doesnt work when i go for http://192.168.1.104:4567/web/. i got this problem in firefox : The connection to the server was reset while the page was loading.
the index site http://192.168.1.104:4567/web/index.php works flawlessly and shows me my index.php file. all i want is to let me show the index file when visiting the root directory, too. /var/www points to the /web directory. i have some ubuntu 12.04 server 64 LTS edition
when i rewert the config lines, the root gives me the index file by default.
You do not need to add AllowOverride All, telling apache to avoid IO by checking existence of .htaccess files in current directory and all parents directories with AllowOverride None is a good recipe for speed. Avoid .htaccess files if you can edit Apache configuration.
Now FallbackResource is a quite new feature and may have some bugs. Did you check the ErrorLog for details? Could you try that with LogLevel debug?
It seems you problems is with directories, maybe you could fix it by enforcing usage of your fallback when a Directory is requested, try to add:
DirectoryIndex rewrite.php
I have developed a site in CodeIgniter, it was working perfectly in my old server as I have changed new server which is in GoDaddy it gives the following error:
Not Found
The requested URL /Foldername/authorise was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache Server at "siteurl" Port 80
actually this process coming after login in this site
Thanks in advance
Did you remember to also move the .htaccess ?
It sounds like a rewrite-problem.
Did you change the base_url in the application/config.php as per new server.
Or if there is mod rewrite problem then follow the steps:
copy rewrite.load and ssl.load from mods-available to mods-enable.
copy default-ssl from sites-available to sites-enable and change as
From:
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
To:
Options Indexes FollowSymLinks MultiViews
RewriteEngine On
AllowOverride all
Order allow,deny
allow from all
To make .htaccess files work as expected, you need to edit this file:
/etc/apache2/sites-available/default
Look for a section that looks like this:
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
You need to modify the line containing AllowOverride None to read AllowOverride All. This tells Apache that it's okay to allow .htaccess files to over-ride previous directives. You must reload Apache before this change will have an effect:
sudo /etc/init.d/apache2 reload
I know this is a silly question, but I would like to know why it is happening so.
I am using wamp server version 2.1. While viewing directories in localhost, the images beside the files are not getting loaded. Refer image below. On inspect of the image, I see it fails to load /icons/folder.gif, where can I find those images and how to load them?
Step 1, Edit "httpd-autoindex.conf" file like;
Alias /icons/ "C:/wamp/bin/apache/apache2.4.2/icons/"
<Directory "C:/wamp/bin/apache/apache2.4.2/icons">
Options Indexes MultiViews
AllowOverride None
Require all granted
</Directory>
Step 2, remove first "#" characters from "httpd.conf" file in
Include conf/extra/httpd-autoindex.conf
and
LoadModule autoindex_module modules/mod_autoindex.so
lines
Step 3, restart all services from wamp try icon
it is pointing to wrong dir in
C:\wamp\bin\apache\YOUR_VERSION\conf\extra\httpd-autoindex.conf
Alias /icons/ "/httpd-2.2-x64/icons/"
<Directory "/httpd-2.2-x64/icons">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
should be
Alias /icons/ "icons/"
<Directory "icons">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
restart server
For whatever reason, you've either removed or moved the icons folder or you've modified a file that points to that folder somewhere on your machine...
The icons folder should reside in: C:\wamp\bin\apache\Apache(version)\
Here are the icons: http://jordanarsenault.com/icons.zip
If they are not already there, put them there.
jsut find the "httpd-autoindex.conf" file from c:\wamp\bin\apache\apache2.4.9\conf\extra folder from apache(your version) folder
find this line "Directives controlling the display of server-generated directory listings".
below this line there will be a address like this "C:/Apache2.2/icons/" (little difference may be there) (2 times)
edit it like this "D:/wamp/bin/apache/apache2.4.9/icons/" (into your directory not the same)
(be careful to use your directory address not the same as above)
it will work...
or check this link and find the answer http://forum.wampserver.com/read.php?2,27544,27861#REPLY
in
/Users/username/Sites/somesite/.htaccess
I have
AllowOverride All
php_value include_path ".:/Users/username/Sites/somesite/inludesFolder:/usr/lib/php"
I have also modified
/etc/apache2/httpd.conf
to
AllowOverride All
and restarted websharing, but it's not finding the additional include path. I'd like to avoid modifying the php.ini or setting this additional include path with the PHP
The AllowOverride within the .htaccess file itself isn't legal like that, and might be causing an error that stops further processing. Since the point of AllowOverride is to restrict what .htaccess files can do, it isn't usually useful within an .htaccess file. Try taking it out and see if it works.
Also, rather than modify /etc/apache2/httpd.conf, Mac OS X's configuration is set up so that you drop a file in /etc/apache2/users to configure your own directory. Files in there will persist across system updates and even upgrades!
For example, on my system, the file `/etc/apache2/mark' is:
<Directory "/Users/mark/Sites/">
Options Indexes MultiViews SymLinksIfOwnerMatch
AllowOverride All
Order allow,deny
Allow from all
</Directory>