enable htaccess apcahe on ubuntu - php

I have an apache server on ubuntu where i have a virtual host that points to my site. Problem is my htaccess not functional.
In my apache2.conf file i have something like
<Directory />
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
if i change AllowOverride for "www" directory htaccess is functional but i get 403 forbidden error. please guide me what i am doing wrong.
regards.

You have to set AllowOverride to all like this.
<Directory "/var/www">
AllowOverride All
</Directory>
After that if you are facing forbidden error then probably you have error in htaccess file. Remove the code in htaccess file then start writing code block by block. By this you can debug error in htaccess file. For more info, you can have a look on this.
https://askubuntu.com/questions/429869/is-this-a-correct-way-to-enable-htaccess-in-apache-2-4-7-on-ubuntu-12-04#answer-429931

Related

Laravel 8 404 api routes in production

I have never had this issue before, it was working perfectly and after I reinstalled the server I now got a 404 when I call my 0.0.0.0/api/students/show.
I did composer production call on SSH to create latest autoloader. Cleared the cache for php artisan, the normal steps to setup a Laravel production app. But I still get 404 when I call the API endpoint.
Maybe the problems is something with chmod rights? Storage, etc. is already done...
In your apache2.conf make sure you've AllowOverride All and not AllowOverride none.
Example
<Directory /var/www/html/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Original Answer
You should not need to write Directory at all.
This is my working page custom .conf file on sites-available folder:
<VirtualHost *:80>
ServerName matiaslauriti.dev
ServerAlias www.matiaslauriti.dev
Redirect 301 / https://matiaslauriti.dev
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName matiaslauriti.dev
ServerAlias www.matiaslauriti.dev
DocumentRoot /var/www/html/public
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/matiaslauriti.dev/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/matiaslauriti.dev/privkey.pem
</VirtualHost>
</IfModule>
What I do have on my apache2.conf is default, I did not change anything:
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options +FollowSymLinks -Indexes
AllowOverride All
Require all granted
</Directory>

phpmyadmin giving 500 error after update the apache2.conf

I am using Linux mint. I am working in a Wordpress, It was not possible navigate a page. I got a answer from a source to change the apache2.conf file like bellow
<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>
But for me the phpmyadmin is not working after this change. For that problem i go for this
Adding
<Directory /usr/share/phpmyadmin>
Options FollowSymLinks
DirectoryIndex index.php
AllowOverride All
in the phpmyadmin.conf file. But still it is working. Is there are anything i have left.
Thanks in advance.

File not found localhost/phpmyadmin macos sierra 10.12.15

i have a problem with phpmyadmin installation via brew, i have modified my root directory to point to /Users/username/Sites in /usr/local/etc/apache2/2.4/httpd.conf.
I have put this in the same file :
Alias /phpmyadmin #{HOMEBREW_PREFIX}/share/phpmyadmin
<Directory #{HOMEBREW_PREFIX}/share/phpmyadmin/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
I use virtual host, so i create a symlink of the folder /usr/shar/phpmyadmin in /Users/username/Sites and create a phpmyadmin.conf like this:
<Directory "/Users/amerej/Sites/phpmyadmin">
Allow From All
AllowOverride All
Options +Indexes
Require all granted
</Directory>
<VirtualHost *:*>
ServerName phpmyadmin.localhost
DocumentRoot "/Users/amerej/Sites/phpmyadmin"
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9071/Users/amerej/Sites/phpmyadmin/$1
</VirtualHost>
I user follow this tutorial for using multiple versions of php :
https://lukearmstrong.github.io/2016/12/setup-apache-mysql-php-homebrew-macos-sierra/
Thank you if can help me i try to solve my problem alone but don't find the solution.

403 Forbidden in Local after modification of apache2.conf

I modified the file etc/apache2/apache2.conf for a WordPress permalink problems, but now I can't access on my localhost.
I changed
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all denied
</Directory>
to
Options Indexes FollowSymLinks
AllowOverride FileInfo
Require all granted
After a2enwrite and reload apache2 my server doesn't work.
I work on Ubuntu 16.04 LTS. Can you help me?

.htaccess ErrorDocument 404 not redirecting

I have tried to create a custom page for the 404 errors to go to, these are the settings in my apache2.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/html>
options Index FollowSymLinks
AllowOverride All
Require all granted
</Directory>
and this is my code in the .htaccess file
RewriteEngine On # Turn on the rewriting engine
ErrorDocument 404 /404.php
RewriteRule ^ls/(\w+)/?$ Pages/misc/profile.php?ss=$1 [NC]
however when I test a page that doesn't exist and it 404s, it doesn't redirect at all to 404.php. For instance if I try a random page like asdf.html, it doesn't show the custom 404 page or even say can't find 404.php, it says it can't find asdf.html which means the redirect never takes place. Can anyone shed some light on why it doesn't redirect?
Thank - you!
p.s. my website resides in /var/www/html for reference

Categories