How to enable rewrite rule and other apache module in centos and ubuntu ?

How to enable rewrite rule modules in apache (Centos and Ubuntu)

for nginx Please scroll down

Centos

httpd -M

vim /etc/httpd/conf.modules.d/00-base.conf

##Add this line

LoadModule rewrite_module modules/mod_rewrite.so

Do not forget to reboot web server

sudo systemctl restart httpd



Ubuntu

How to enable module in ubuntu ?

Enable and restart the web server

a2enmod rewrite

service apache2 restart

How to configure rewrite rule in virtualhost configuration file ?

Edit Virtualhost files

vim /etc/httpd/conf.d/techouse.conf
vim /etc/apache2/sites-available/techouse.conf

<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

How to enable the rewrite rule in .htaccess configuration file ?

Open .htaccess file and copy this line – RewriteEngine on

cd /var/www/html/techouse
vim .htaccess

RewriteEngine on

How to list module in centos ?

Run this command in terminal

ls /etc/httpd/modules | grep mod_rewrite

Output

mod_rewrite.so

How to check the module is loaded or not ?

 

grep -i LoadModule /etc/httpd/conf/httpd.conf | grep rewrite

output
LoadModule rewrite_module modules/mod_rewrite.so



How to enable rewrite in ubuntu and centos while using nginx web-server.

Open VirtualHost file and add below mentioned lines

vim /etc/nginx/conf.d/techouse.conf

## Add this line in location / - try_files $uri $uri/ /index.php?$args;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}

techouse

I love helping beautiful people like you. I love hanging out with my dogs.

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

× How can I help you?