XAMPP httpd.conf setup to allow for mod_rewrite rules - php

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>

Related

Phabricator install. Rewrite rules are not configured correctly

I've followed the Phabricator Configuration Guide, and after installing all dependencies, I'm facing the following message:
Request parameter '__path__' is not set. Your rewrite rules are not configured correctly.
This message is shown when I try to access www.cleverbit.com.br/phabricator/webroot/
I have a apache2.conf file configured just the way the docs suggested:
<VirtualHost *>
# Change this to the domain which points to your host.
ServerName cleverbit.com.br
# Change this to the path where you put 'phabricator' when you checked it
# out from GitHub when following the Installation Guide.
#
# Make sure you include "/webroot" at the end!
DocumentRoot /var/www/html/phabricator/webroot
RewriteEngine on
RewriteRule ^(.*)$ /index.php?__path__=$1 [B,L,QSA]
</VirtualHost>
<Directory />
Options FollowSymLinks
AllowOverride All
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride All
Require all granted
</Directory>
<Directory "/var/www/html/phabricator/webroot">
Require all granted
AllowOverride All
</Directory>
What's exactly wrong with my apache rewrite configuration?
Apache does not have inheritance inside Directory statements, so you also need the AllowOverride All line inside the Directory block for /var/www/html/phabricator/webroot.
To avoid confusion, I would get rid of the /var/www Directory block, unless you have another VirtualHost that uses it (in which case, you might want to move Phabricator out from that directory to avoid accidentally creating back doors).
Setting the following rewrite rules fixed this for me
RewriteEngine on
RewriteRule ^/rsrc/(.*) - [L,QSA]
RewriteRule ^/favicon.ico - [L,QSA]
RewriteRule ^(.*)$ /index.php?__path__=$1 [B,L,QSA]
thanks to https://gist.github.com/sparrc/b4eff48a3e7af8411fc1

Symfony 2 removing app.php

i have been through lots of topic about this, and the thing is still not working so i was wondering if you could help me to see what i am doing wrong.
My goal is to have neat URL as www.name.com without the app.php nor web, and i have changed over and over my Virtualhost & Htacces that my page are kind of gone for now^^ (Yeah so pro)
So first, i have enabled the rewrite mod, and i am running a 2.2.2 apache version.
Here is my VirtualHost files :
<VirtualHost *:80>
ServerName steeph
ServerAlias name.com
DocumentRoot /home/ksc/www/symfony/web
<Directory /home/ksc/www/symfony/web>
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/project_error.log
CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>
I have also tried with line on :
<Directory "path">
DirectoryIndex app.php
Options -Indexes
AllowOverride All
Allow from All
</Directory>
which are not working either
For my htaccess i have tried at the symfony files root (and removing the /web from the virtual host) which was a fail, and i tried with this htaccess
<IfModule mod_rewrite.c>
RedirectMatch permanent ^/app\.php/(.*) /$1
RewriteEngine On
RewriteBase /web/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
I tried with the "RedirectMatch permanent ^/app.php/(.*) /$1" and without
So i have been to like a dozen of stackoverflows and i have tried even not popular answer but it still not working, so i would really appreciate some help here
Thanks a lot!
If Linux... enable Rewrite
sudo a2enmod rewrite
sudo service apache2 restart
You could just copy the one from symfony standard edition
-> https://github.com/symfony/symfony-standard/blob/master/web/.htaccess
and it would just work fine.

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>

apache 2.4 php and laravel - friendly urls

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.

.htaccess file not working on linux

I have configured Amazon EC2 instance with Amazon Linux AMI 64 bit
and I have uploaded my website, whole code is working but issue with .htaccess
RewriteRule are not working. I have done all changes in httpd.conf file but I think it might be a permission issue.
please help me regarding this.
here is my htaccess code
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^friosworld\.com$ [NC]
RewriteRule ^(.*)$ http://www.friosworld.com/$1 [R=301,L]
and one more thing I have found via googling
httpd.conf file code
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
I think problem is in this block of code. but I don't know what is the problem!
I have also changed AllowOverride None to AllowOverride All but still not working!!
Got the solution. thanks for your time.
<Directory />
Options FollowSymLinks
AllowOverride All # AllowOverride None to AllowOverride All
</Directory>
AND
DocumentRoot "/home/mydirectory/website" //change this default path to my path
Now its working fine
Thank you all

Categories