I am having a problem with a website in production. I have been working on this website in a sub-to-dir and have now placed the project on the true website. But now I keep getting this:
403 Forbidden
You don't have permission to access /index.html on this server.
The website doesn't give this error on the sub-to-dir version. The .htaccess file which I am using in my root:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Can someone explain to me what I am missing? I have changed the server.php to index.php and back but that also doesn't make a difference. I have also tried giving all files and folder 777 permission but no luck.
edit the file /etc/apache2/apache2.conf
<Directory /var/www/yourlaravelapp/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
and sudo a2enmod rewrite and restart apache, that may work for you.
Just Re give the permission
sudo chmod -R 777 /path/to/index.html file/
I know this question have more answer on this page. But It is not work fine for me. I don't know why. I followed step by step as instruction. Could you please help me check.
Thanks for your support
The URL looks liks is : examplemysite.com
The link work well if I add index.php for it.
Change config.php -> $config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
htaccess is located same level with index.phpenter image description here
The content of htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
In to enable mod_rewrite for Windows and Linux, do the following:
Windows:
Find and open the file .http.conf. This will be located in your Apache install folder.
Make a backup of http.conf which you can restore from, if anything were to go wrong
Find the line #LoadModule rewrite_module modules/mod_rewrite.so and remove the hash ‘#’enable-mod-rewrite-1
Locate the block within the directory tags as indicated below and change to:
Options All
AllowOverride All
Finally, restart apache server and your browser. The .htaccess rewriting should now be working.
Linux (Ubuntu as an example):
Activate the mod_rewrite module with
sudo a2enmod rewrite
and restart the apache
sudo service apache2 restart
To use mod_rewrite from within .htaccess files edit the virtualhost
sudo nano /etc/apache2/sites-available/000-default.conf
Below “DocumentRoot /var/www/html” add the following lines:
<Directory “/var/www/html”>
AllowOverride All
</Directory>
Restart the server again:
sudo service apache2 restart
I haVE my page hosted in Amazon EC2, it was working well in the root of the apache server (/var/www/html). But i want to have an other page in the same server so i start moving it to a subfolder (/var/www/html/alqip/public) so i can setup the second website in (/var/www/html/page2).
The site is developed in Laravel 5 and it is showing a blank page without login any error in laravel logs and system logs either (syslog, apache logs, php logs).
The permissions of storage folder are 777.
This is my .htaccess in public/ folder:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
And my page.config in /var/apache2/sites-available:
<VirtualHost *:80>
ServerName alqip.com
ServerAlias www.alqip.com
DocumentRoot "/var/www/html/alqip/public"
<Directory "/var/www/html/alqip/public">
AllowOverride All
</Directory>
</VirtualHost>
I think the problem is in Laravel, not in server configuration, what do you think? Thanks!
Verify the firewall is down and if you are on centos check the configuration of the selinux. For default the selinux is enable edit the file /etc/selinux/config
SELINUX=disabled
After disbled you have to reboot you server
after installing Laravel you must create the .env file using the .envexample template.
the next problem you will have is permission issues
Its caused because php is running as another user by default.
so to fix this do
sudo nano /etc/php/7.0/fpm/pool.d/www.conf
then edit the
user = "put user that owns the directories" group = "put user that owns the directories"
then:
sudo systemctl reload php7.0-fpm
I need some help with laravel 4 application i need to remove Index.php from url i have tried the solution that has been mentioned in laravel documentation
Pretty URLs
Apache
The framework ships with a public/.htaccess file that is used to allow URLs without index.php. If you use Apache to serve your Laravel application, be sure to enable the mod_rewrite module.
If the .htaccess file that ships with Laravel does not work with your Apache installation, try this one:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
any Suggestions :) ?
FOR LAMP SERVER
Try the following steps,
Activate the mod_rewrite module with,
sudo a2enmod rewrite
and restart the apache
sudo service apache2 restart
To use mod_rewrite from within .htaccess files (which is a very common use case), edit the default VirtualHost with
sudo nano /etc/apache2/sites-available/000-default.conf
Search for “DocumentRoot /var/www/html” and add the following lines directly below:
<Directory "/var/www/html">`
AllowOverride All
</Directory>
Save and exit the nano editor via CTRL-X, “y” and ENTER.
Restart the server again:
sudo service apache2 restart
this worked for me
<Directory "/var/www/html">`
AllowOverride All
</Directory>
uncomment 'LoadModule rewrite_module modules/mod_rewrite.so' in apache httpd.conf
in 'public' folder check .htaccess file (created by default)
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I have read long posts and threads but nothing works then i found this and it works for me.
The easiest way to do this (and the way I always use) is to open up your Command prompt or Terminal and cd into the main directory of your project then run "php artisan serve". That's it. You're done. Don't believe me? Check out http://localhost:8000 and admire your Laravel work.
http://michaelbrooks.co.uk/post/laravel-localhost-removing-public-index-php
just go to your apache settings folder, i use wamp so myne is
C:/wamp/bin/apache/apache2.4.9/conf/httpd.conf - file
// located on line 154 precisely...
#LoadModule rewrite_module modules/mod_rewrite.so
// to
LoadModule rewrite_module modules/mod_rewrite.so
restart WAMP and BOOM!.. it works.
mod_rewrite apache module may not be enabled by default. enable it and retry.
Try this:
a2enmod rewrite
And it will works
Currently I am using the hosting with lightspeed server. Hosting says mod_rewrite is enabled but I can't get my script working there. Whenever I try to access the URL, it returns 404 - not found page.
I put the same codes at another server which is running with Apache. It's working over there. So I guess, it's the .htaccess and mod_rewrite issue.
But Hosting support is still insisting with me that their mod_rewrite is on, so I would like to know how can I check whether it's actually enabled or not.
I tried to check with phpinfo(), but no luck, I can't find mod_rewrite there, is it because they are using lightspeed?
Is there any way to check? Please help me out. Thank you.
FYI: my .htaccess code is
Options -Indexes
<IfModule mod_rewrite.c>
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
</IfModule>
I tried like this also
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
But same result.
from the command line, type
sudo a2enmod rewrite
if the rewrite mode is already enabled, it will tell you so!
To check if mod_rewrite module is enabled, create a new php file in your root folder of your WAMP server. Enter the following
phpinfo();
Access your created file from your browser.
CtrlF to open a search. Search for 'mod_rewrite'. If it is enabled you see it as 'Loaded Modules'
If not, open httpd.conf (Apache Config file) and look for the following line.
#LoadModule rewrite_module modules/mod_rewrite.so
Remove the pound ('#') sign at the start and save the this file.
Restart your apache server.
Access the same php file in your browser.
Search for 'mod_rewrite' again. You should be able to find it now.
If you are using a virtual hosts configuration file, make sure the virtual host in question has the directive AllowOverride All somewhere like this:
<VirtualHost *:80>
...
<Directory "directory/of/your/.htaccess">
AllowOverride All
</Directory>
</VirtualHost>
Basically, this states to allow processing of all .htaccess directives.
This works on CentOS:
$ sudo httpd -M |grep rewrite_module
Should output rewrite_module (shared)
console:
<VirtualHost *:80>
...
<Directory ...>
AllowOverride All
</Directory>
</VirtualHost>
sudo a2enmod rewrite
sudo service apache2 restart
If apache_get_modules() is not recognized or no info about this module in phpinfo(); try to test mod rewrite by adding those lines in your .htaccess file:
RewriteEngine On
RewriteRule ^.*$ mod_rewrite.php
And mod_rewrite.php:
<?php echo "Mod_rewrite is activated!"; ?>
PHP's perdefined apache_get_modules() function returns a list of enabled modules. To check if mod_rewrite is enabled , you can run the following script on your server :
<?php
print_r(apache_get_modules());
?>
If the above example fails, you can verify mod-rewrite using your .htaccess file.
Create an htaccess file in the document root and add the following rewriteRule :
RewriteEngine on
RewriteRule ^helloWorld/?$ /index.php [NC,L]
Now visit http://example.com/HelloWorld , You will be internally forwarded to /index.php page of your site. Otherwise, if mod-rewrite is disabled , you will get a 500 Internel server error.
Hope this helps.
If
in_array('mod_rewrite', apache_get_modules())
returns true then mod-rewrite is enabled.
you can do it on terminal, either:
apachectl -M
apache2ctl -M
taken from 2daygeek
If this code is in your .htaccess file (without the check for mod_rewrite.c)
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
and you can visit any page on your site with getting a 500 server error I think it's safe to say mod rewrite is switched on.
You can use php function
apache_get_modules
and check for mod_rewrite
<pre>
<?php
print_r(apache_get_modules());
?>
</pre>
http://in2.php.net/apache_get_modules
If you are in linux system, you can check all enable modules for apache2(in my case) in the following folder:/etc/apache2/mods-available
cd /etc/apache2/mods-available
to type: ll -a
if you want to check the available modules for php (in this case php 7 )
folder /etc/php/7.0/mods-available
cd /etc/php/7.0/mods-available
to type: ll -a
I know this question is old but if you can edit your Apache configuration file to AllowOverride All from AllowOverride None
<Directory "${SRVROOT}/htdocs">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
just make a new page and add this code
<?php
if(!function_exists('apache_get_modules') ){ phpinfo(); exit; }
$res = 'Module Unavailable';
if(in_array('mod_rewrite',apache_get_modules()))
$res = 'Module Available';
?>
<html>
<head>
<title>A mod_rewrite availability check !</title></head>
<body>
<p><?php echo apache_get_version(),"</p><p>mod_rewrite $res"; ?></p>
</body>
</html>
and run this page then find will able to know module is Available or not if not then you can ask to your hosting or if you want to enable it in local machine then check this youtube step by step tutorial related to enable rewrite module in wamp apache
https://youtu.be/xIspOX9FuVU?t=1m43s
Wamp server icon -> Apache -> Apache Modules and check the rewrite module option
This code worked for me:
if (strpos(shell_exec('/usr/local/apache/bin/apachectl -l'), 'mod_rewrite') !== false) echo "mod_rewrite enabled";
else echo "mod_rewrite disabled";
First you check if the module is installed
apachectl -M
It it does not shows on the list, you must activate it:
a2enmod rewrite
Now, restart your server and test
systemctl restart apache2
You just need to check whether the file is there, by typing
cat /etc/apache2/mods-available/rewrite.load
The result line may not be commented starting with #
I was having the exact problem, I solved it by clicking custom structure, then adding /index.php/%postname%/ and it works
Hope this saves someone the stress that I went through finding what the heck was wrong with it.
Simply create a php file in root and add following code
<?php
if (in_array('mod_rewrite', apache_get_modules())) {
echo "mod_rewrite is enabled";
} else {
echo "mod_rewrite is not enabled";
}