anoyne good with htaccess? need some simple help

Joined
12 Feb 2006
Posts
17,312
Location
Surrey
i'm no good with htaccess it would appear. everything i try doesn't work so hoping someone can help me out.

this is what i have got that my hosting company put to make it so the website root is within a folder public_html/grp, rather than just public_html (i need this to keep my shared hosting account tidy)

Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?mayergroup\.co.uk$
RewriteRule !^grp/ /grp%{REQUEST_URI}  [L]

what i want now is 2 things.

1. Make it so that if someone goes to the website without www., it redirects them to the site with www.

2. if someone goes to the link www.mayergroup.co.uk/grp it shows the home page. i'd like it so they are redirected to www.mayergroup.co.uk.

i thought the below would do that, but in fact the last line is doing the opposite, so redirecting when there is no www., to www.mayergroup.co.uk/grp.

Code:
RewriteCond %{HTTP_HOST} ^mayergroup\.co.uk$ [NC]
RewriteRule ^(.*)$ http://www.mayergroup.co.uk/$1 [R=301,L]

redirect 301 [url]http://www.mayergroup.co.uk/grp/[/url] [url]http://www.mayergroup.co.uk/[/url]

what do i need to do?
 
Soldato
Joined
16 Jun 2013
Posts
5,375
//Rewrite to www
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mayergroup.co.uk/[nc]
RewriteRule ^(.*)$ http://www.mayergroup.co.uk//$1 [r=301,nc]

//301 Redirect Old File
Redirect 301 http://www.mayergroup.co.uk/grp http://www.mayergroup.co.uk/

I normally use this site hasn't failed me yet;
http://www.htaccessredirect.net

Edit: instead of redirect to remove the grp ref why not try a rewrite rule on it?

RewriteRule ^grp/(.*)$ /$1 [L,NC,R]
 
Last edited:
Back
Top Bottom