0

So I redirected one of my domains (which we'll call domain.com) into one of my subdirectories (which we'll call file) and I'm trying to achieve links that will cut down the index?page=, force the www, and have trailing slashes available for all pages.

Currently I have

domain.com/index?page=about or domain.com/splash

where I'd like www.domain.com/about/ or www.domain.com/splash/

This is what I have so far:

RewriteEngine On

RewriteCond %{HTTP:Host} ^(?:www\.)?domain\.com$ 
RewriteCond %{REQUEST_URI} !^/file/ 
RewriteRule ^(.*) file/$1 [NC,L,NS]

ErrorDocument 404 http://domain.com/splash

I'm not well versed with Apache if you can't tell, haha.

Cee
  • 1
  • 4

1 Answers1

0

I would go with:

RewriteEngine On

RewriteCond   %{HTTP:Host}        !^www\.domain\.com$
RewriteRule   ^(.*)$              http://www.domain.com/$1 [L,R=301]

RewriteCond   %{REQUEST_FILENAME} !-f
RewriteRule   ^([\w\-]+)$         /$1/ [L,R=301]

RewriteCond   %{REQUEST_FILENAME} !-f
RewriteRule   ^(.*)$              /index.php?page=$1       [L]

ErrorDocument 404                 /splash/

Be careful to use 302 (temporary) redirections instead of 301 (permanent) ones during your debugging phase, as your browser would "remember" the permanent redirections and not take into account the new configuration of your website.

Mathieu Rodic
  • 6,637
  • 2
  • 43
  • 49