.htaccess file not working on linux - php

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

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.

Magento 1.9 api/rest 404 error

Recently I have moved a magento 1.9 but the api/rest url is 404ing.
The site is running on php 7.0 on a virtual host.
I have added
<Directory /var/www/html/magento/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
But this isn't working :/
I have also cheched the .htaccess file for
RewriteRule ^api/rest api.php?type=rest [QSA,L]
The api/rest works fine on my local version but just not on the live server.
Any help with this would be a god send :)
Solution
In the .conf file I needed to remove Options Indexes FollowSymLinks
<Directory /var/www/html/magento>
AllowOverride All
# New directive needed in Apache 2.4.3:
Require all granted
</Directory>
Hope this helps :)
Make sure you use Options -MultiViews instead of Options FollowSymlinks.

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

Categories