Report this

What is the reason for this report?

Mediawiki URL redirect with .htaccess

Posted on April 12, 2015

I use Mediawiki on my site’s subdomain (viki). I changed my url structure.

Old url structure: http://viki.gameofthronestr.com/index.php/Lannister_Hanesi

New url structure: http://viki.gameofthronestr.com/Lannister_Hanesi

I just deleted “/index.php/” from url.

I want to redirect old urls to news on .htaccess. (I use Apache) How i redirect old URL to new?

I tried that but doesnt work:

RewriteEngine On 
RewriteBase / 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^viki/(.*)$ /index.php?title=$1 [PT,L,QSA] 
RewriteRule ^viki/*$ /index.php [L,QSA] 
RewriteRule ^viki$ /index.php [L,QSA] 
RewriteRule ^index.php/(.*)$ /$1 [R=301,L]


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!

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.

I do not believe that the MediaWiki one-click image has the Apache rewrite module enabled by default so there are a couple changes that are needed to have apache use a redirect setup configured in an .htaccess file.

1.) Enable the module with the command

a2enmod rewrite

2.) In your virtualhost configuration file in /etc/apache2/sites-enabled find the “AllowOverride” setting for your main directory and change “AllowOverride None” to “AllowOverride All”, this allows configuration variables in your .htaccess file to override your virutalhost defaults.

3.) Restart apache for the changes to take effect with the command:

service apache2 restart

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.