Use URL Rewriting with language code

June 9, 2015 1.2k views
Joomla Apache LAMP Stack DNS Ubuntu

Hi Guys,

I need your help setting my htaccess url rewriting correctly, I built international joomla website and it works fine but I want to remove index.php from the url I searched a lot and read many articles regarding removing index.php from the url but no luck.

Without enabling URL Rewriting the url looks like:
I want it to look like;

Below the steps I did:
First, I enabled Mod_Rewrites: sudo a2enmod rewrite
Second, Set Use URL Rewriting to yes in joomla global configuration
Last, I renamed htaccess.txt to .htaccess

When I did that the site crashed and the browser showed The requested URL /en/ was not found on this server.

I built the site under a virtual host /home/bashar/www/MainSite/

.htaccess code:

IndexIgnore *                                                                                  

Options +FollowSymlinks                                                                        
Options -Indexes                                                                               

RewriteEngine On                                                                               

RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]                                   

RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]                             
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]                                 
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
 RewriteRule .* index.php [F]

 RewriteBase /MainSite/

 RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
 RewriteCond %{REQUEST_URI} !^/index\.php
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule .* index.php [L]

Please Advice,

Be the first one to answer this question.