Rewrite in Mediawiki, remove index.php, .htaccess

Rewrite in Mediawiki, remove index.php, .htaccess - .htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about apache, htaccess, redirects, 301-redirect, .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :


I've just installed Mediawiki on Apache and I want the URL should be:



localhost/Main_Page/
localhost/Special:Recent_Changes
...


instead of:



localhost/index.php/Main_Page/
localhost/index.php/Special:Recent_Changes


I've tried many times and in many ways but it still doesn't work. Any suggest for a "exactly" what to do, step by step. Mediawiki docs didn't talk about .htaccess. It had only Nginx and lighttpd.


Solution :

You can have clean URLs with the following step.



Install the wiki into http://localhost/w and NOT into http://localhost/wiki then Modify the following in LocalSettings.php after you have set it up:



$wgArticlePath = "/wiki/$1";


In the ROOT directory place the following .htaccess file:



RewriteEngine on

## uncomment this rule if you want to redirect to http://localhost/wiki/Main_Page
# RewriteRule ^/$ /wiki/Main_Page [R]

## do the rewrite
RewriteRule ^wiki/?(.*)$ /w/index.php?title=$1 [L,QSA]


Try the following code:



Options +FollowSymLinks
RewriteEngine on
RewriteCond %REQUEST_FILENAME !-f
RewriteCond %REQUEST_FILENAME !-d
RewriteRule ^(.*)/(.*)$ /mediawiki/index.php?title=$1&actions=$2 [L]


This MediaWiki documentation does talk about .htaccess.


Additionally, if you would like to do some further testing, give the htaccess tester tool a try. It allows you to specify a certain URL as well as the rules you would like to include and then shows which rules were tested, which ones met the criteria, and which ones were executed.

Comments

Popular posts from this blog

.htaccess rewrite wildcard folder paths from host

Using .htaccess to set a cookie and 301 redirect