remove index.php from url in laravel in ubuntu - mod-rewrite

I have tried several ways to remove index.php from my URL.
problem like
url not working(i want this): http://mysite.in/our-story
url working(i don't want this): http://mysite.in/index.php/our-story
1) I have tried to enanble rewrite_mod but it is already enabled.
2) I have tried to this code into .htaccess file but problem is not solved.
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L] </IfModule>
any file installation is remaining?? then tell me?? (but i have installed everything.)
my 000-default file is:
ServerAdmin webmaster#localhost
ServerName mydomain.in
DocumentRoot /var/www/mysite/public
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/mysite/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
Please give me solution for that.
thanks friends!!!

Change AllowOverride to all instead of none.
by Jason Lewis

Check if .htaccess permissions are set to www-data (or corresponding Apache user)

Related

Get this "Not Found The requested URL was not found on this server." Apache configuration or Laravel issue?

I have a problem: after installing and setting up https my site stopped working.
I can only navigate to the index page. If I select login or create an account I get and error saying that the page doesn't exist:
Not Found The requested URL was not found on this server
I don't know if this is Apache's or Laravel's fault.
I am using Virtualmin, Ubuntu 20.4 lite, apache, and Laravel.
My directory on the server is /home/domain/public_html/. Under public_html I have my Laravel project with all the files and folders.
This are the setting used for Apache, config through virtualmin.
SuexecUserGroup "#1000" "#1000"
ServerName *mydomain*.se
ServerAlias www.*mydomain*.se
ServerAlias mail.*mydomain*.se
ServerAlias webmail.*mydomain*.se
ServerAlias admin.*mydomain*.se
DocumentRoot /home/*mydomain*/public_html/public
ErrorLog /var/log/virtualmin/*mydomain*.se_error_log
CustomLog /var/log/virtualmin/*mydomain*.se_access_log combined
ScriptAlias /cgi-bin/ /home/*mydomain*/cgi-bin/
ScriptAlias /awstats/ /home/*mydomain*/cgi-bin/
DirectoryIndex index.php index.php4 index.php5 index.htm index.html
DocumentRoot "/home/*mydomain*/public_html/public"
<Directory "/home/*mydomain*/public_html/public">
Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
AddType application/x-httpd-php .php
AddHandler fcgid-script .php
AddHandler fcgid-script .php7.4
FCGIWrapper /home/*mydomain*/fcgi-bin/php7.4.fcgi .php
FCGIWrapper /home/*mydomain*/fcgi-bin/php7.4.fcgi .php7.4
</Directory>
<Directory /home/*mydomain*/cgi-bin>
Allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>
RewriteEngine On
RewriteCond %{HTTP_HOST} =webmail.*mydomain*.se
RewriteRule ^(?!/.well-known)(.*) https://*mydomain*.se:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.*mydomain*.se
RewriteRule ^(?!/.well-known)(.*) https://*mydomain*.se:10000/ [R]
RemoveHandler .php
RemoveHandler .php7.4
FcgidMaxRequestLen 1073741824
<Files awstats.pl>
AuthName "*mydomain*.se statistics"
AuthType Basic
AuthUserFile /home/*mydomain*/.awstats-htpasswd
require valid-user
</Files>
Alias /dav "/home/*mydomain*/public_html/public"
<Location /dav>
DAV on
AuthType Basic
AuthName "*mydomain*.se"
AuthUserFile /home/*mydomain*/etc/dav.digest.passwd
Require valid-user
ForceType text/plain
Satisfy All
RemoveHandler .php
RemoveHandler .php7.4
RewriteEngine off
</Location>
IPCCommTimeout 9999
<Directory "/home/*mydomain*/public_html/public/phpmyadmin">
</Directory>
Can someone please help me? I searched for answers on the forum and tested different settings but nothing works for me.

htaccess problem in https url codeigniter

I am having problem in my htaccess file. Would someone help me to identify the problem.
I actually removed the index.php in
foldername/application/config/config.php
I added this in vhost of my apache and restarted services
<VirtualHost *:80>
ServerAdmin user#mai.com
DocumentRoot "C:/server/Apache24/htdocs/foldername"
<Directory "C:/server/Apache24/htdocs/foldername">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ServerName https://foldername.com
ServerAlias https://foldername.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
This works actually on my localhost, but when I configure the url, I added https because I need it to be in https, the htaccess doesn't work.
Here's my htaccess:
RewriteEngine On
RewriteRule ^(application) - [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
Thank you in advance.

laravel httpd document root doesn't change

it's my first time to use laravel and config apache and I've a problem with apache document root, it doesn't change.
It always show apache homepage
I'm using a vm with virtualbox, and my conf.d file finish with this lines:
DocumentRoot "/var/www/laravel/public"
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName 192.168.56.3
#ServiceAlias www.test.laravel.com
DocumentRoot /var/www/laravel/public
</VirtualHost>
<Directory "/var/www/laravel/public">
Options FollowSymLinks
ReWriteEngine On
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</Directory>
Do you know what is wrong?
Thank you

RewriteBase with WAMP not working (vhost)

I have a problem, let me explain.
Rewrite_module is enabled on WAMP
My host is mapped:
127.0.0.1 localhost
127.0.0.1 mydomain.com
My vhost declared on WAMP:
<VirtualHost *: 80>
ServerAdmin contact#mydomain.com
DocumentRoot "E:/wamp/www/subfolder/"
ServerName mydomain.com
ErrorLog "logs/mydomain.com.log"
CustomLog "logs/mydomain.com.log" common
<Directory "E:/wamp/www/subfolder /">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow, deny
Allow from all
</ Directory>
</ VirtualHost>
For now, no problem, mydomain.com arrives on E:/wamp/www/subfolder/
My projects are in sub folders such as E:/wamp/www/subfolder/my-project/
I have a htaccess with:
<Mod_rewrite.c IfModule>
RewriteEngine On
RewriteBase /my-project/
RewriteRule ^index\php$ - [L]
RewriteRule ^assets/css/(.*) /my-project/content/themes/assets/css/ $ 1 [QSA, L] [QSA, L]
RewriteCond% {REQUEST_FILENAME}! F
RewriteCond% {REQUEST_FILENAME}! -d
RewriteRule. /my-project/index.php [L]
</ IfModule>
My problem comes here. If I go on mydomain.com/my-project/ it comes to the site with no problem, but the css (for example) are not loaded, because the link is:
mydomain.com/content/themes/assets/css/
It should have:
mydomain.com/my-project/content/themes/assets/css/
I think the RewriteBase not working and I do not know why.
Thank you very much and sorry for my english.
I think you misunderstood the point of a Virtual Host.
You should create a Virtual Host for EACH of your projects so something like this
<VirtualHost *: 80>
ServerAdmin contact#mydomain.com
DocumentRoot "E:/wamp/www/subfolder/project1"
ServerName mydomain1.com
ErrorLog "logs/mydomain.com.log"
CustomLog "logs/mydomain.com.log" common
<Directory "E:/wamp/www/subfolder/project1">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow, deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *: 80>
ServerAdmin contact#mydomain.com
DocumentRoot "E:/wamp/www/subfolder/project2"
ServerName mydomain2.com
ErrorLog "logs/mydomain.com.log"
CustomLog "logs/mydomain.com.log" common
<Directory "E:/wamp/www/subfolder/project2">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow, deny
Allow from all
</Directory>
</VirtualHost>
This makes each project look and react like it was a single website on its own unique Apache instance and makes moving your projects to live servers more reliable.
You also do not need a .htaccess now unless this one project actually requires it.

Ubuntu 12.04 Laravel and mod rewrite

localhost/mysite/public - working
localhost/mysite/public/index.php/tasks - working
localhost/mysite/public/tasks - NOT WORKING ERROR 404
I tried almost everything and still have problem.
I have got mod rewrite on - i used : sudo a2enmod vhost_alias rewrite
and restarted the server
my .htaccess file:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
my etc/apache2/sites-avaliable/default its like:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
when I change AllowOverride to All - only "localhost/" is working but i cant run any sites like "localhost/mysite" .
I have tried to add to default file a next virtual host like:
<VirtualHost *:80>
DocumentRoot /var/www/mysite/public/
<Directory /var/www/mysite/public/>
AllowOverride All
</Directory>
</VirtualHost>
but it is not working at all.
First, if you are using Laravel 3 make sure that you have updated /application/config/application.php and made the "application index" var to a null value, like "". https://github.com/laravel/laravel/blob/master/application/config/application.php#L42
If you've already done that, try setting up a vhost. It sounds like you are using Apache 2.
First create an additional vhosts file, for example /etc/apache2/sites-available/laravel
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName laravel.dev
ServerAlias *.laravel.dev
DocumentRoot /home/kriss/projects/laravel/public
</VirtualHost>
Then update your /etc/hosts file and add
127.0.0.1 laravel.dev
Then (and this may be the step you missed before)
sudo a2ensite laravel
This will make a sim link in /etc/apache2/sites-enabled to your vhost config file.
Finally restart your server:
sudo service apache2 restart
You should be able to connect with the url http://laravel.dev, and your rewrites should be working.
Run the following command in Terminal to enable mod_rewrite.
sudo a2enmod rewrite
Now restart Apache.
sudo service apache2 restart

Resources