htaccess conflicting with MediaWiki htaccess

79 views Asked by At

I have the following code in my htaccess file:

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^wiki/(.*)$ /index.php?title=$1 [PT,L,QSA]
RewriteRule ^wiki/*$ /index.php [L,QSA]
RewriteRule ^wiki$ /index.php [L,QSA]

This shorten the URL from http://example.com/w/index.php?title=Page_title to example.com/wiki/Page_title.

I would also like to redirect example.com to www.example.com, but I am not sure on how I should implement this into the existing htaccess code without conflicting with other rules.

How can this be done?

1

There are 1 answers

0
Jon Lin On BEST ANSWER

RIght under RewriteBase /, add:

RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R]