Hard .htacess question???

by guest
2 replies
Hi guys,

I'm really having a problem with this htacess file - i'm not geat, and am trying to put it together with code on the web.

I'm trying to make the following happen:

Code:
http://site.com redirect to http://www.site.com
http://www.site.com/folder redirect to http://www.site.com/folder/


AND put it all together as a rewrite redirect to the index...

http://www.site.com/page-name/ redirect to http://www.site.com/index.php?p=page-name

So a www is always added.
A forward slash is always added.
and anything after the domain is actually poinint to index as a variable.

Can anyone help?

Thanks so much!
#hard #htacess #question
  • Profile picture of the author Bruce Hearder
    Question 1 :
    http://site.com redirect to http://www.site.com

    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^site\.com
    RewriteRule ^(.*)$ http://www.site.com/$1 [R=permanent,L]

    Question 2 :
    http://www.site.com/folder redirect to http://www.site.com/folder/

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ http://www.site.com/$1/ [L,R=301]

    Final part :

    RewriteRule ^(.*)/$ http://www.site.com/index.php?p=$1 [L,R=301]

    Hope this helps

    Bruce
    {{ DiscussionBoard.errors[1835201].message }}
  • Profile picture of the author guest
    Perfect mate!

    Thanks so much.
    {{ DiscussionBoard.errors[1849307].message }}

Trending Topics