2

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?

magnusl
  • 45
  • 7

1 Answers1

2

RIght under RewriteBase /, add:

RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R]
Jon Lin
  • 142,182
  • 29
  • 220
  • 220