Setting directives in Vagrant (and ProcessWire) - php

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.

Related

Laravel: no joy after MAMP upgrade from 3.4 to 4.1

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.

.htaccess file not parsing after upgrade to ubuntu 16.04

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.

How to set Apache to accept override from .htaccess

I have tried to run php in .html file and failed despite trying all solution suggested here. Someone suggested it maybe because Apache is not setup to accept .htaccess overrides. Maybe that is the reason. Now the question is how do I setup Apache?
To be able to use .htaccess files, the directive AllowOverride must be set for the directory into which you want to put .htaccess files. E.g.:
<Directory "/usr/local/httpd/htdocs">
AllowOverride All
</Directory>
This must be set in the core httpd.conf file of Apache. If you're on a shared host, you likely have no access to that (and that's correct, for security reasons).

apache url rewrite connection reset on root directory

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

my zend framework application is not reading htaccess file even after enabling url rewrite in apache

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

Categories