Rewrite Rule in .htaccess file for subdomain


I have configured my Blog on For this I have an Apache Conf file which direct the user to /blog directory.

I have two major issues:

1.) After installation, when I try to open admin panel from, it throws 500 Internal Server Error. It seems the rewrite engine is not properly coded in the .htaccess file.

Also when I try to open the admin link, it takes me to: in place of This is bound to throw an error.

2.) When I open the site,, it opens normally, but when I click on the default 1st blog, again the Server throw 500 Internal Error and takes me to in place of

I think it has something to do with .htaccess file which sends rewrite information to server, which is incorrect.

Can you please advice what should be the edit for: <pre> RewriteRule ^(.*)$ index.php/$1 [L] </pre> so that I can remove index.php from the URL as well as keep the link to while browsing the blog?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Also Check this code for redirection with .index.htm to non www url

Options +FollowSymLinks

RewriteEngine on

RewriteCond %{HTTP_HOST} !^ [NC]

RewriteRule ^(.*)$$1 [L,R=301]


RewriteCond %{REQUEST_URI} ^(.*)//(.*)$

RewriteRule . [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.htm\ HTTP/

RewriteRule index\.htm$ [R=301,L]\

Let’s start simple:

in your apache config (/etc/httpd/conf/httpd.conf or /etc/apache2/apache2.conf), do you have this uncommented: <pre> NameVirtualHost *:80 </pre> If not, uncomment that, and restart httpd

Next, most blogging software won’t allow multiple domains in one folder. You’ll need a separate folder per domain/sub-domain. If you’re not doing this, you will need to separarate that.

Almost done. Let’s go back to the apache config (Look at my 2nd line for the file again)

Do you have something like this for your vhost: <pre> AllowOverride All </pre> or is it something like this: <pre> AllowOverride None </pre> If the latter, it won’t work, and you’ll need to change it (This doesn’t apply to the cgi-bin or error folders, just your document root).

Next to last: do you have mod_rewrite enabled? For Ubuntu, you would run this: <pre> a2enmod rewrite; service apache2 reload </pre> Finally: do you have the permission set for the web user (apache/www-data) to have read access to your .htaccess file?

If you’re unsure of any of the answers to these questions, just let me know.


Is it wrtite code from www to non www version.

RewriteEngine On

RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]