As I am suffering a weird redirect problem and I read MAMP could be the cause I decided to upgrade it.
I have my virtual hosts set and they are enabled in the conf.
I set correct ports and set PHP version to 5.6.31 (it was 5.6.10).
What happens when I start the servers is I can open the welcome screen of the laravel project (project.dev) but then the routes don't work with error 404. Example project.dev/home or project.dev/login etc.
Any clue?
--- edit
I added this to my vhost and now it's working. Not sure if all the stuff there is needed as I just copied from the web. Strangely I didn't have anything of this in the past and it worked. Could it be apache was configured to allow mod_rewrite or something?
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>
In your httpd.conf file set AllowOverride directive from None to All, for example:
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
The default in Apache 2.3.9 and later is None, previous versions is was All. From the online docs:
When this directive 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.
When this directive is set to All, then any directive which has the
.htaccess Context is allowed in .htaccess files.
Related
Just got a new dedicated server from a reputable hosting company for my new website project.
It runs Centos 7.9/WHM with Apache 2.4+PHP 7.4 Package.
PHP-FPM as handler.
I ran some test with some php files in my website folder and I noticed that any .php files is accessible without his extension. Without any .htaccess file!
"https://www.example.com/myinfo.php" is Accessible.
"https://www.example.com/myinfo" Should be inaccessible without any .htaccess + rules.
It's annoying me a lot because I know it's gonna bring me some issues during my website project.
Where could these rule be as I am not using any htaccess file?
Thanks for any information you can give me.
As Magnus Eriksson said: You could be having multiviews enabled in your vhost. Try turning them off, restart apache and check if the issue is resolved. There could also be rewrite rules directly in your vhost.
As you have cPanel installed, my guess is the /etc/httpd/httpd.conf, and /var/cpanel/templates/apache2_4/ea4_main.default. Before you edit the ea4_main.default, copy it to ea4_main.local: cp -a /var/cpanel/templates/apache2_4/ea4_main.default /var/cpanel/templates/apache2_4/ea4_main.local, and only edit the ea4_main.local file. Please be careful when editing it, as it could mess up a lot of things. I would suggest you to ask questions on cPanel Forums if you are using cPanel, because this must be a cPanel related issue. And, I am not responsible if any problems occur, I have warned you already.
Edit:
Since you linked your httpd.conf file, I found this:
<Directory "/">
AllowOverride All
Options MultiViews FollowSymLinks IncludesNOEXEC Indexes ExecCGI
</Directory>
Change it to:
<Directory "/">
AllowOverride All
Options -MultiViews +FollowSymLinks +IncludesNOEXEC +Indexes +ExecCGI
</Directory>
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.
I upgraded a digital ocean box from 14.04 to 16.04 and ran in to some issues. The .htaccess file is not being parsed. I can throw garbage at the top of the file which normally breaks a server and it does not matter, leading me to believe it is not being parsed. My ultimate goal is to parse html files as php.
Virtual host settings were not changed after upgrade and worked before.
You can see an instance of the test droplet here: http://162.243.70.81/
I spent about 3 hours digging through other solutions including:
Checking conf file:
//Part of conf file
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
Checking if rewrite module is enabled
Module rewrite already enabled
service apache2 restart
Review .htaccess file (this is the first few lines and the random chars should result in a 500 if working)
kldlkldfg
AddType application/x-httpd-php .html .inc
editing mime types and looking if some php extensions are not commented out.
When I did the upgrade I did keep old conf files when it said the previous were modified and offered to overwrite or keep. I kept the defaults. Keep in mind everything worked before the upgrade and can be seen at www.pylamdyes.com
When I upgraded to php7 I had to disable php5.
That is all of the relevant info I can think to give, happy to try anything or post specific info as requested. Thanks for looking at this.
Define your virtualhost correctly by removing the <Directory /> entry and use this instead:
<Directory /var/www/www.pylamdyes.com>
Require all granted
Options FollowSymLinks
AllowOverride all
</Directory>
About Directory / it should be in server config (outside virtualhosts) like:
<Directory />
Require all denied
AllowOverride none
</Directory>
Also note: if you have access to the server configuration, there is no reason to use .htaccess files. .htaccess files are meant for people without admin rights to configure the web server.
If you need access for another directory, such as the target for that Alias, then define it in the same fashion as the documentroot Directory entry I defined. Policy is and should always be, deny all to /, and give access to the specific directories from where you serve files.
I'm having a problem where it seems like my Vagrant VirtualBox isn't reading the .htaccess file for a site I have mapped out. (a proccesswire site)
I've don't know enough about Vagrant to find where I should be editing the directives so that my .htaccess file will be read. As far as I've gathered from searching I need to set a directive like so:
<Directory /var/www>
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
It seems the primary offender is the AllowOverride is typically set to "None" and needs to be "All". But I have put this in a httpd.conf file in apache and I'm guessing that isn't correct.
A bit more information: When I installed PW in the site root I got this error: " Unable to determine if Apache mod_rewrite (required by ProcessWire) is installed. ". As a result when I try to access a part of the CMS, that is usually handled by rewrite rules, the url (/admin or /processwire by default) just reroutes me to the homepage.
Also, I can delete everything in .htacess or add garbage to it and no errors occur. This tells me that .htacess isn't even being read.
I appreciate the help.
I have built a Zend Framework application. By configuring it to read routes.ini file, my application after deployment is not going to any routes but only default route is working. I have total of 4 routes in this application and none of them are working. Apache is showing a Not Found error.
I had look at .htaccess file it is perfect and in my local it is working fine. I also checked the permissions. It is having read and write rights for www-data. I also checked Apache URL rewrite module.
I did this again and tried:
sudo a2enmod rewrite
Still same issue.
My apache error log says that file does not exist.
Please tell me where I have gone wrong.
After researching for hours , I could notice that there was a very minor and sensitive mistake in the apache vhost file .
my entry was like this
<Directory /var/www/your_project>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
But actually my entry should be as per mssb some what like this
<Directory /var/www/your_project>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory
Since I am not an experienced webmaster I couldn't noticed one simple thing which is
AllowOveride option which was set to None
I referred to Core apace documentation today in order find where I was wrong .
The reason for not picking .htaccess file is as follows
When AllowOveride directive is set to None, then .htaccess files are
completely ignored. In this case, the server will not even attempt to
read .htaccess files in the filesystem.
When this directive is set to All, then any directive which has the
.htaccess Context is allowed in .htaccess files.
I personally felt like Posting this entire solution for the problem to help others who may face a similar problem in future
Once again I would like to thank you all for responding to this post
Try following steps to mod_rewrite
sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/
sudo gedit /etc/apache2/sites-enabled/000-default
add following codes
<Directory /var/www/your_prject_name>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
# Commented out for Ubuntu
#RedirectMatch ^/$ /apache2-default/
</Directory>
then restart the server
sudo /etc/init.d/apache2 restart