PHP was working fine before enabling mods. I was trying to use rewrite mods. I enabled mods with-
sudo a2enmod rewrite
sudo systemctl restart apache2
Also restarted apache also restarted computer. This is my htaccess file-
RewriteEngine On
#Accept loading of actual files and folders
RewriteCond %{REQUEST_FILENAME}% !-f
RewriteCond %{REQUEST_FILENAME}% !-d
#send everything else to index page
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]
This is directory I added to conf-
<Directory /var/www/html/folderwithhtaccessfile>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory /var/www/html/otherfolder>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
</Directory>
This is my php file-
<label>hey hey hey</label>
<?php
echo "bla bla bla";
?>
When I run this in browser page Result is -
<label>hey hey hey</label>
<?php
echo "bla bla bla";
?>
It appears php code is not read by php preprocessor and directly served to browser. Also I have adjuscent folders with php code they have also stopped working not just the one with htaccess file. What might be the problem? Any ideas?
Here is conf-
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory /var/www/html/folderwithhtaccessfile>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory /var/www/html/otherfolder>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Update
I partially resolved my problem by enabling php with-
a2enmod php8.2
Now php is working fine. Javascript is working fine. CSS on the other hand is not working. Files are available and served but no effect can be seen.
.conf.htaccessfile. Does PHP start working again?Order allow,deny allow from allwhich should beRequire all grantedin Apache 2.4 syntax