How to enable mod_rewrite?

Solution

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".

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.

The following code block is sample rewriting code that is used in WordPress:

RewriteEngine On #Taking note that this line must be there in order to enable mod_rewrite

RewriteBase /

#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteCond %{REQUEST_URI} ^.*/wp-admin$
RewriteRule ^(.+)$ $1/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule� ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
RewriteRule� ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to Solve My Website Page Not Found Error?

Solution Troubleshooting guideIf you have already signed up for a hosting account with us,...

Your Control Panel (cPanel) Video Tutorials

Solution You will be a pro in no time with cPanel's video tutorials. These tutorials allow you...

How to enable register_globals?

Solution Some softwares requires Register_globals to be on. The server global option as part...