NukeViet is a fairly popular open source CMS in Vietnam, especially in schools and government agencies. One question comes up over and over: how do you drop index.php from the path, turning:
https://example.com/index.php/news/article.html
into:
https://example.com/news/article.html
Beyond just looking cleaner, tidy URLs are better for SEO and much easier to share.
The common situation
You have checked everything: the web server is Apache, the rewrite module is enabled, you turned on the rewrite option in the admin panel, and the URLs still have index.php in them. This is exactly the situation I ran into.
The reason is that NukeViet stores the rewrite support flag in a separate config file, and in some cases the admin interface cannot write the new value into that file.
The fix
Open this directory over FTP or through your host’s file manager:
/data/config/
Look for a file named along the lines of config_ini.yourdomain.php. If my domain is nguyenlap.net, the file is:
config_ini.nguyenlap.net.php
Open it and find this line:
$sys_info['supports_rewrite'] = false;
Change the value to true:
$sys_info['supports_rewrite'] = true;
Save the file, then go into the admin panel and run system cleanup to clear the cache. The index.php will be gone from the URLs.
Check these if it does not work
If every subpage now returns a 404, rewriting is not actually working at the server level. Check these one at a time:
Is the rewrite module enabled? On a VPS running Apache:
sudo a2enmod rewrite
sudo systemctl restart apache2
Is the .htaccess file being read? In the Apache config, the web directory has to allow overrides:
<Directory /var/www/html>
AllowOverride All
</Directory>
AllowOverride None is the most common reason .htaccess gets ignored completely without any error message.
Does the NukeViet .htaccess exist? NukeViet ships a sample file called htaccess.txt in the root directory. Rename it to .htaccess if you do not have one.
If the server runs Nginx
.htaccess only means something to Apache. On Nginx you declare the rewrite inside the server block:
location / {
try_files $uri $uri/ /index.php?$query_string;
}
After editing, test the config and reload:
sudo nginx -t
sudo systemctl reload nginx
The nginx -t step is well worth doing: it catches syntax errors before the reload, so you do not take down the whole web server over a missing semicolon.
After the URLs change
If the site has been running for a while and Google has indexed the old URLs, do not leave both forms live. Add a 301 redirect from the old shape to the new one so you keep your rankings and avoid duplicate content:
RewriteCond %{THE_REQUEST} \s/index\.php/(.*)\s [NC]
RewriteRule ^ /%1 [R=301,L]
Put this in .htaccess, above NukeViet’s existing rewrite rules.