the problem is that my wordpress website works but the pages give a 404 page not found error , so i followed these steps :
enabled mod_rewrite
my .htaccess file looks like this :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
3- when i edit the value in /etc/apache2/apache2.conf
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
TO
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
the website crashes whenever i change the above value , i also tried to re install my apache server and nothing seems to work .
I am trying to access api's written in laravel though postman.
By using the below format link i am able to access the api's
http://example.cloudapp.net/suven/index.php/api/register
But how to access without index.php name in the url
I have 2 laravel projects created in /home/azureuser
Below is my /etc/apache2/sites-enabled/api.conf file
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName example.cloudapp.net
Alias /suven /home/azureuser/webservices/public
<Directory /home/azureuser/webservices/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
Alias /quiz /home/azureuser/quizapp/public
<Directory /home/azureuser/quizapp/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
SetEnv APPLICATION_ENV dev
LogLevel warn
</VirtualHost>
Below is my .htaccess file in /webservices/public directory
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
#RewriteBase /webservices/public
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
Below is my routes.php file
Route::get('/', function ()
{
return view('errors/503');
});
Route::group(array('prefix' => 'api/'), function()
{
Route::post('/register','UserAuthController#register');
Route::post('/login','UserAuthController#login');
});
Route::group(array('middleware' => 'appuser_auth','prefix' => 'api/'), function()
{
Route::post('/changepassword','UserAuthController#changePassword');
});
I'm not sure what the problem is I followed the steps to remove index.php
Added to .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Selected Custom Structure
http://11.33.55.77/%pagename%/
Any page I visit is a 404 for example
http://url.com/faq = 404
The requested URL /faq was not found on this server.
Make sure the permalink of the faq page is actually /faq, if that's set up properly make sure mod_rewrite is enabled in your apache
Make sure mod_rewrite is enabled. sudo a2enmod rewrite.
This did not work for me
instead go to apache2/sites-available/default-000.conf
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
copy and paste the following configuration
Please help me, I'm working on a Laravel using the latest version of xampp & do not know what the cause of my problem is.
This route is working fine:
Route::get('/', function () {
return 'aa';
});
This route gives an error "Object not found!":
Route::get('about', function () {
return 'aaa';
});
httpd.vhosts:
<VirtualHost test.loc:80>
DocumentRoot "C:/xampp/apps/test.loc/public"
ServerName test.loc
<Directory "C:/xampp/apps/test.loc/public">
#AllowOverride All - when I use this, I get a "Access forbidden!" for all routes
Require all granted - this works for the main route, other routes give "errors".
</Directory>
/public/.htaccess:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
I faced exactly the same problem, but finally this worked for me.
.....
<Directory "C:/xampp/apps/test.loc/public">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
Add this to your httpd.vhosts file
<VirtualHost test.loc:80>
ServerName test.loc
DocumentRoot "C:/xampp/apps/test.loc/public"
<Directory "C:/xampp/apps/test.loc/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Have you tried adding a slash before the name?
like this:
Route::get('/about', function () {
return 'aaa';
});
Im using laravel 4.
I have a view nest.blade.php and the corresponding controller NestController.php:
Controller content:
class NestController extends BaseController {
public function showView()
{
return View::make('nest');
}
}
Route:
Route::get('/nest', 'NestController#showView');
When I go to url/nest it doesnt work.
When I go to url/index.php/nest it does work.
Obviously I just want it to be /nest without the index.php.
How can i resolve this?
My htaccess:
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>
Pretty URLs
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]
For more related help, check this answer.
I enabled the mod_rewrite module in the Apache HTTP server, restarted Apache service and tested again and it WORKED!!!
Below is the code i used to enable mode_rewrite;
1) Un-Hash this line in Apache/conf/httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
2) Create a new configuration for "sample-project" without modifying the default configuration in the httpd.conf file
Directory "C:/Apache24/htdocs/sample-project">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
Directory>
Be Alert! If it is not working even after enabling rewrite module. You need to change the line "AllowOverride None" to "AllowOverride All" in httpd.conf.
As #The Alpha alerted, Laravel don't need to be configured for this purpose.
When you change the line AllowOverride None to AllowOverride All in httpd.conf be sure that you do it inside <directory ...> that contains valid path.
Example
<Directory "/var/www/html"> #check path
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
For some reasons the answers above are not working for me, so here is the only one that worked for me.
I am using ubuntu 18.04 amd64 as my development server environment.
So I modified apache.conf file located at/etc/apache2
From:
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted
To:
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted
And Also From:
<Directory /usr/share> AllowOverride None Require all granted
To
<Directory /usr/share> AllowOverride All Require all granted
After that, you need to restart apache using sudo service apapche2 restart command in the terminal
Now I can access the page without using index.php in the URL
Credit goes to: joshymatheww # Laracasts servers discussion channel on
Aug 5, 2017
Login to the terminal
sudo nano /etc/apache2/apache2.conf
After line
<Directory /var/www/>
.
.
.
</Directory>
and paste below code
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
Now Ctrl+O and then Ctrl+M and then Ctrl+x
Now restart apache server
sudo service apache2 restart
First of All you need to set AllowOverride All in /etc/apache2/apache2.conf. Find the following block:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
DirectoryIndex index.php
Require all granted
</Directory>
then you need to modify /etc/apache2/mods-available/dir.conf and move index.php first :
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>
AND DO NOT FORGET: Run a2enmode
sudo a2enmod rewrite
and then
sudo service apache2 restart
This way you apply it for all your laravel projects (inside /var/www/ folder).
set this in your .htaccess
DirectoryIndex index.php
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/index.php [L]
Try the following .htaccess. I never had any trouble with that on a server or localhost environment.
DirectoryIndex index.php
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/index.php [L]
</IfModule>