PDA

View Full Version : 301 re-direct htaccess linux


Stationery-Direct
9th August 2010, 18:19
Hi guys

What code do I add to my htaccess file so that the main domain doesn't forward to a new URL, just any pages after the /

For example

www.mysite12345.co.uk (http://www.mysite12345.co.uk) needs to just show the holding page.

www.mysite12345.co.uk/anypath (http://www.mysite12345.co.uk/anypath) needs to 301 re-direct to another domain.

Any ideas?

Faevilangel
9th August 2010, 18:22
redirect 301 /folder/index.html http://www.domain.co.uk/

Stationery-Direct
9th August 2010, 18:24
Thanks for that although I don't want to specify the folder, I want any path after the / to forward, any ideas?

Faevilangel
9th August 2010, 18:25
Thanks for that although I don't want to specify the folder, I want any path after the / to forward, any ideas?

I have no idea, it may need some complicated code to do it or may not even be possible

KM-Tiger
9th August 2010, 19:28
If you use Rewrite rather than Redirect you can have a RewriteCond that will exclude the index.html, something like:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^index\.html$
RewriteRule /(.*) http://your.other.domain/$1 [R=301]

The '!' negates the regex that follows, (regex = the bit between '^' and '$'), so it means don't Rewrite index.html. Note the '\.', the dot needs to be escaped with a '\' inside the regex.

Can't guarantee that will work, but hopefully move you in the right direction.

marieluy143
10th August 2010, 03:24
wOw..Thanks for this code..