How to enable mod_rewrite for default vhost?

NethServer Version: 7.6


It looks like a very simple question but without a simple answer : how do I enable mod_rewrite and correct .htaccess file handling for the default vhost ?

I want to host a wordpress site directly on www.domain.tld and domain.tld. after migration I see that all the links to pages are 404.

As far as I can see with php_info(), mod_rewrite is not enabled but I don’t really understand where to enable it.

Anybody can help ?


Hi pagaille.

Create the file to be read/add to httpd.conf
VHOST_DIRECTORY_NAME is the name given to your vhost

cat > /etc/httpd/conf.d/z_WordPress.conf <<'EOT'
# ************************************** 
# To enable Apache to read the .htaccess in WordPress
<Directory "var/lib/nethserver/vhost/VHOST_DIRECTORY_NAME">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted


Restart Apache

systemctl restart httpd

Create .htacces in the root of your vhost (VHOST_DIRECTORY_NAME)

# ************************************** 
# Pour les permaliens
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /affaires/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /affaires/index.php [L]

# **************************************
# Permet au serveur de suivre les liens symboliques dans les répertoires concernés.
Options +FollowSymLinks

# Empêche d'afficher le contenu des répertoires s'ils ne contiennent aucun DirectoryIndex
# c'est-à-dire index.html, index.php etc...
Options -Indexes

If you use WordFence then after installing it:

# **************************************
# Wordfence WAF
<IfModule mod_php5.c>
        php_value auto_prepend_file 
<Files ".user.ini">
<IfModule mod_authz_core.c>
        Require all denied
<IfModule !mod_authz_core.c>
        Order deny,allow
        Deny from all

# END Wordfence WAF

Ajust right

chmod 444 .htaccess

Ajust owner/group

chown apache:apache .htaccess

For more details see:

For Wordfence see:

Those two documents are RC-001


Merci @michelandre !

But I think we should use the template system don’t we ?

Moreover, I’m using the default vhost, the one in /var/www/html

Hi pagaille,

There is no template for httpd.conf in 7.6.1810

Change directly in httpd.conf under <Directory "/var/www/html">

##### AllowOverride None
AllowOverride All


1 Like

Oh I didn’t know. And indeed I just found out that the AllowOverride wasn’t correctly set in that httpd.conf file.


Hi again pagaille,

I saw that you downloaded the WordPress PDF.

There is an error in it:
When you specify a file to be included in the backup data, there is no “/” at the end.
The “/” is for specifying a directory to be included in the backup data.
If there is one “/” for a file, it will be included in /etc/backup-data.d/custom.include but the backup will not backup it because it will see that it is a file and not a directory.

Especially for: /etc/profile.d/ which is a file, not a directory.