Back to Knowledge Base
Knowledge Base Web Hosting How to enable mod_rewrite?

How to enable mod_rewrite?

Web Hosting 07/11/2026
<p><span style="font-family: arial, helvetica, sans-serif; font-size: small;">Solution</span></p>
<p><span style="font-family: arial, helvetica, sans-serif; font-size: small;">If you're facing problems getting mod_rewrite to work even after placing the code into your .htaccess file, it might be because you left out the first line, that looks like: "RewriteEngine On".<br /><br />This line of code should always be placed on the first line of your rewrite code, so that it enables the mod_rewrite feature that rewriting requires.<br /><br />The following code block is sample rewriting code that is used in WordPress:<br /><br />RewriteEngine On #Taking note that this line must be there in order to enable mod_rewrite<br /><br />RewriteBase /<br /><br />#uploaded files<br />RewriteRule ^(.*/)?files/$ index.php [L]<br />RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*<br />RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]<br /><br /># add a trailing slash to /wp-admin<br />RewriteCond %{REQUEST_URI} ^.*/wp-admin$<br />RewriteRule ^(.+)$ $1/ [R=301,L]<br /><br />RewriteCond %{REQUEST_FILENAME} -f [OR]<br />RewriteCond %{REQUEST_FILENAME} -d<br />RewriteRule . - [L]<br />RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]<br />RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]<br />RewriteRule . index.php [L]</span></p>
Was this article helpful?