I'm focusing on an internet site and i'm confronted with a large problem is:

  1. i would like my traffic http://www.example.com/ to http://example.com or http://www.example.com/folder/ to http://example.com/folder/

(Note: the important thing factor here's it may work with infinite quantity of subfolders or pages so far as it is the same root domain)

  1. I wish to rewrite http://example.com/name to http://example.com/folder/page.php?page=$title aside from some web addresses like http://example.com/css that we will specify. This time around around, the url still shows http://example.com/name the page visited however , page continues to be rewritten. This really is unlike the very first scenario that that changes the url within the address bar.

Now this is exactly what i've:

<IfModule mod_rewrite.c>
   Options +FollowSymlinks
    Options -Multiviews
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

   RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
   RewriteCond %{REQUEST_URI} !^/(candidates|css|employers|layout|pics|securimage)/?$

   RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
   RewriteRule ^([^/]+)/?$ employers/page.php?page=$1 [L]
</IfModule>

The problems am getting using what i've above are:

  1. It doesn't redirect http://www.example.com/ to http://example.com.

  2. It appears to rewrite well for http://www.example.com/name however when i've got a url and among the exceptions like http://example.com/css it changes the hyperlink to http://example.com/css/?page=css.

Please how do i fix this.

Many thanks.

You need to separate your conditions ans rewrite rules:

For that www subdomain:

RewriteCond %{HTTP_HOST} ^www.example.tld$
RewriteRule ^(.*) http://example.tld/$1 [QSA,R=301]

then for that QSA redirection, until the file is available:

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