apache 2.4 php and laravel - friendly urls - php

I have been pulling my hair off since the last few hours trying to get my friendly urls work.
I have apache 2.4 with php set up. the app is built using laravel 4
so while this http://machinename:90/helpsystem/index.php/categories works the following does not work http://machinename:90/helpsystem/categories
I have enabled the mod_rewrite module in apache's httpd.conf file
Also I have added this to my alias module section of the httpd.conf
ScriptAlias /helpsystem "c:/Apache24/htdocs/helpsystem/public"
public being the the public folder of the laravel app
my directory section looks like this
<Directory "c:/Apache24/htdocs/helpsystem/public">
Options Indexes Includes FollowSymLinks MultiViews
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
and the .htaccess file looks like this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
Can you please let me know what am I doing wrong ?
thanks

AllowOverride All should fix your problem, after restarting apache2
<Directory c:/Apache24/htdocs/helpsystem/public/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

Check out Apache's upgrade guide from 2.2 to 2.4.
Since 2.4+ is shipped out on most linux distros now (particularly Debian/Ubuntu), you'll see this crop up a lot. I see you're on Windows, so it looks like whatever you happen to be using as updated as well! Specifically,
Order allow,deny
Allow from all
Has been replaced with Require all granted as Apache now uses mod_authz_host.

Related

Update .htaccess to reduce length of URL

I am sending a website live and I was getting a 500 internal Error.
So I have googled around and I have been able to find a solution.
I have added modifications to the code below.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/public/index.php
RewriteRule ^(.*)$ /public/index.php/$1 [L]
</IfModule>
The issue is that, when I enter an URL such as www.app.com, I obtain www.app.com/public/index.php
Is there a way to update the .htaccess so that requests made to www.app.com will be redirected to www.app.com/public/index.php without showing /public/index.php in the URL?
Try modifying /etc/apache2/sites-available/default (default location on most Linux distributions, yours may be different).
Change AllowOverride None to AllowOverride All so you should have:
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www>
Options FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
Then restart apache with systemctl restart apache2.

XAMPP httpd.conf setup to allow for mod_rewrite rules

I recently inherited a unfinished CodeIgniter project from a company that has sub-contracted me to complete it. I'm having some trouble with the mod_rewrite rules that the previous dev has implemented as I am unable to view the project on my localhost.
From what I can gather the rules applied are just to get rid of the "index.php" portion of the URL. The project works perfectly live so I believe that the issue lies with the way I have set up my xampp httpd.conf file. As per instructions found on this site and other sources I have mad the following changes to the httpd.conf file:
LoadModule rewrite_module modules/mod_rewrite.so
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
DocumentRoot "C:/Users/Me/Documents/Github"
<Directory "C:/Users/Me/Documents/Github">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
When I go to localhost and click on the project I am just getting a 404 error. I've been struggling with this for a couple of days now and don't know how to proceed. Can you see an issue with the way I've set up the httpd.conf file? Thanks for the help!
EDIT: Added the rewrite rules being used.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
SetEnv ENVIRONMENT development
This could be a wild guess but when I look at my Xampp apache config it has
..
allow from all
Require all granted
</Directory>

htaccess rewrite stopped working after update

I am using this code in my htaccess file, and I am confident that it is right, but it is not working on my new server. You can find my phpinfo file here: http://www.saint57records.com/test.php. I just updated my apache, so I don't know if it is something there. I have tried finding other information but I can't find any.
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/artists/index.php.*
RewriteRule ^artists/(.+)$ artists/index.php?artist=$1 [L]
Check httpd.conf or apache2.conf inside , AllowOverride must be set to All
If you are using Ubuntu check this in /etc/apache2/apache2.conf
<Directory /your/directory>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>

How to fix permalinks not working with Vagrant and Wordpress?

I am using Vagrant to build up a little Wordpress development VM. When I select permalinks (postname) then the page from an article doesn't load. However, when I select the standard link (i.e page id) all is working good.
I've used the service PuPHPet to build the VM.
My settings can be found here
I am using Wordpress 3.9.1 and Apache2
I've enabled mod_rewrite be executing:
a2enmod rewrite
And my .htaccess file from Wordpress is as follows:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /svisa/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /svisa/index.php [L]
</IfModule>
# END WordPress
it has the following permissions and ownership:
-rw-rw-rw- 1 vagrant www-data 248 May 30 14:52 .htaccess
My virtualhost file for the site (/var/www/svisa/) can be found here.
from my host computer, I browse to the site via adress: http://wpdev-vm/svisa/
where wpdev-vm is the name of the vm.
Does anybody know what I am missing to make the permalinks work?
I solved the problem myself.
In the default apache configuration, under /etc/apache2/sites-enabled, where mine is called 15-default.conf
This was declared under the document root:
<Directory "/var/www">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
I had to change AllowOverride None to AllowOverride All. Thus you'll get the following:
<Directory "/var/www">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
After that, the permalinks started working.
The (correct) answer above says that you need to change AllowOverride None to AllowOverride All in your xxx-default.conf file found in the /etc/apache2/sites-enabled directory.
However, in my vagrant box (precise64) none of the allowOverride or <Directory /var/www/>... code was present to begin with in the default.conf file.
I ended up having to add all of it between the VirtualHost tags, like below:
<VirtualHost *:80>
# Other stuff
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
And then having to restart apache, like below, for it to work.
sudo service apache2 restart

symfony 1.4.8 conflict with PHP 5.4.7 and Apache 2.4.3

I recently updated my Xampp server (from 1.7 >> 1.8) and since then I'm no longer able to run my projects written in Symfony 1.4.8.
It says:
You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
But it has permissions!
Actually it works fine with older version of Xampp. Is it possible that Symfony 1.4.8 is not compatible with Apache 2.4 or PHP 5.4? I'm using Windows 8 Enterprise, but also tested on Windows 7 Ultimate and same problem exists.
Any suggestions would be appreciated.
Here is my config:
NameVirtualHost 127.0.0.1:1111
Listen 127.0.0.1:1111
<VirtualHost 127.0.0.1:1111>
DocumentRoot "D:\AMir\PROJECTS\BarzinMehr\web"
DirectoryIndex index.php
<Directory "D:\AMir\PROJECTS\BarzinMehr\web">
AllowOverride All
Allow from All
</Directory>
Alias /sf C:\xampp\htdocs\symfony\data\web\sf
<Directory "C:\xampp\htdocs\symfony\data\web\sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
And here is my .htaccess
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
# uncomment the following line, if you are having trouble
# getting no_script_name to work
#RewriteBase /
# we skip all files with .something
#RewriteCond %{REQUEST_URI} \..+$
#RewriteCond %{REQUEST_URI} !\.html$
#RewriteRule .* - [L]
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
after struggling with this problem for so many days, i finally found the solution and i'm taking it here in favour of anyone else who might face this problem. according to this article (thanks to the writer!) all i had to do was this:
change each Directory block like this:
<Directory "your address">
AllowOverride All
Allow from All
</Directory>
to
<Directory "your address">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
</Directory>
it seems that Allow was dropped in favor of new directive Require in apache 2.4(according to documentation for version apache 2.4)
Try removing the .htaccess file and accessing the index.php file directly. If this works (or at least produces a PHP error, rather than an apache error), it probably means that mod_rewrite is not enabled, and the .htaccess is not working as expected.
I would recommend removing the:
<IfModule mod_rewrite.c>
and it's closing tag from the .htaccess file if they are present because if the module isn't installed, it's better to get an error that it isn't installed, rather than the site just not work in a strange way.
If the above doesn't solve the issue, take a look at apache's error log - this often contains clues.

Categories