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.
Related
On Live server, to resolve 404 error when trying to access any page, changed below setting in httpd.conf
<Directory "/usr/local/apache/htdocs">
Options Includes Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
But on next day it gets reset to below
<Directory "/usr/local/apache/htdocs">
Options Includes Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Really hoping that it was going to work, but no go. This is what .htaccess looked like after I changed the permalink option:
<Directory />
Options +FollowSymLinks
AllowOverride All
</Directory>
<Files .htaccess>
order allow,deny
deny from all
</Files>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
The pages are still not accessible. Changing AllowOverride None to AllowOverride All works, but it resets again to default setting somehow.
404 page not found error appears often even after changing httpd.conf and .htaccess.
Note: mod_rewrite is already installed
I added this rule to my (htaccess) file on my root web server so that should anyone try to access lets say /web server/test then index would take the 'test' input as string but it is not working it keeps on saying error 404 not found.
My code is below:
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
</IfModule>
php_flag magic_quotes_gpc off
RewriteEngine on
RewriteRule ^([^./]{3}[^.]*)$ /index.php?page=$1 [QSA,L]
Are there any faults in this?
Below is my apache2 conf file.... As I get error 500 after changing my settings to override all.
Now I am getting error 500 ... so that I can provide more information... below is my htaccess file code
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
</IfModule>
php_flag magic_quotes_gpc off
RewriteEngine On
RewriteRule ^([^./]{3}[^.]*)$ /index.php?page=$1 [QSA,L]
And my apache2.conf file.....
<Directory />
Options FollowSymLinks
AllowOverride All
#Require all denied
Order allow,deny
Allow from all
</Directory>
<Directory /usr/share>
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
two key points you need attention .
ensure your root directory can be overwrite by apache , please check the apache configuration , correct setting by below:
<Directory />
Options FollowSymLinks Multiviews
#AllowOverride none
AllowOverride All
Order allow,deny
Allow from all
# Require all denied
</Directory>
check your rewrite rules and ensure them can work. On your case i test following rules and work fun on my local.
RewriteEngine On
RewriteRule ^(\w+)$ /index.php?page=$1 [L]
Hope this can help you!
I have followed instructions in another SO post to enable mod_rewrite on EC2. I have this setup:
# Configure /var/www/html
<Directory "/var/www/html">
Options FollowSymLinks
AllowOverride All
DirectoryIndex index.html index.php
Order allow,deny
Allow from all
</Directory>
RewriteEngine on
RewriteRule ^/?jobs$ jobs.html [L]
However when I visit http://example.com/jobs it fails to rewrite. I have checked with phpinfo() and mod_rewrite is enabled in PHP. What else could be preventing rewrite?
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
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