cancel
Showing results for 
Search instead for 
Did you mean: 

mod_rewrite on 'Homepages'

paulcobb
Grafter
Posts: 146
Registered: ‎30-07-2007

mod_rewrite on 'Homepages'

I am familiar with using .htaccess in my webspace but am having a few probs with mod_rewrite.
Looking at past threads I am making the assumption that mod_rewrite is enabled on the web server?
If so, I am attempting to redirect my username.force9.co.uk address to a new URL.
Suggestions please.
Paul
6 REPLIES 6
Ben_Brown
Grafter
Posts: 2,839
Registered: ‎13-06-2007

Re: mod_rewrite on 'Homepages'

mod_rewrite is enabled on the homepages servers, and seems to work fine when I play with it. I'm guessing you want something similar to this:

RewriteEngine On
RewriteRule .* http://www.your-site.com/

That's the simplest way to do it, but might not suit your specific needs. Does your domain also point to your homepages space? If so you'll need to have a "RewriteCond" to make sure it doesn't apply to your domain, otherwise you'll create an infinite redirection loop.
paulcobb
Grafter
Posts: 146
Registered: ‎30-07-2007

Re: mod_rewrite on 'Homepages'

Many thanks,
I have been fiddling round with the syntax of my statement trying to get it working
RewriteRule (.*) http://www.mysite.co.uk/$1 [R=301,L]
which is similar (and works fine elsewhere) - but not the same as yours!
RewriteRule .* http://www.your-site.com/
Seems to work fine though.
Paul
paulcobb
Grafter
Posts: 146
Registered: ‎30-07-2007

Re: mod_rewrite on 'Homepages'

Looking a little deeper now at the folders within HTDOCS where other domains point:
What is needed for the RewriteCond to enable continued access to these and all child folders under them?
I can configure to get access to the folders but not other pages and folders at the next level down.
Ben_Brown
Grafter
Posts: 2,839
Registered: ‎13-06-2007

Re: mod_rewrite on 'Homepages'

You'd want something like:

RewriteCond %{REQUEST_URI} !^/<foldername>/.*

above the RewriteRule. This will skip the rule for the folder and anything below it.
paulcobb
Grafter
Posts: 146
Registered: ‎30-07-2007

Re: mod_rewrite on 'Homepages'

That is what I had been trying with myself.
When I add the RewriteCond the browser hangs.
I just added one line with the folder name replacing <foldername> in your example.
Just to be clear my domain is pointing at that folder.
Without the RewriteCond the RewriteRule works fine and redirects as it should.
This is being applied on ftp.plus.com rather than homepages, I don't think that should be an issue?
EDIT : I have tried this on 'hompages' and the result is the same.
FURTHER EDIT:  FF reports a redirect loop !
Ben_Brown
Grafter
Posts: 2,839
Registered: ‎13-06-2007

Re: mod_rewrite on 'Homepages'

It sounds like you need another RewriteCond, to exclude your domain name. BTW ftp.plus.net and homepages.plus.net are effectively the same thing.
Something like:
RewriteCond %{HTTP_HOST} !\.mydomain\.com$