Redirect from one site to another site using .htaccess

Status
Not open for further replies.

NaHoW

Active Member
635
2010
107
0
Hello,

I'm looking for a way to redirect users from one website to another.
But there's something special.

I don't want this:
www.oldsite.tld/file1 -> www.newsite.tld

I want this:
www.oldsite.tld/somerandomdirectory/anotherrandomdirectory/somerandomfile -> somerandomdirectory/anotherrandomdirectory/somerandomfile


With "somerandomfile" I mean a totally random file, there can be 1000's of these. So I don't want a .htaccess file with a 1000 lines, just this one. Which mean only "oldsite.tld" has to be replaced and the rest of the string needs to stay unchanged.

I've also been thinking if it would be possible to apply this to everything but to "/admin", not sure if that would work.

I know this is possible, I've tried a few things with "$" but I can't get it working.

This is the code I already have from the current site:

Code:
RewriteEngine On 

RewriteRule ^/?sport-events/([a-zA-Z]+)/([a-zA-Z0-9-]+) index.php?menu=sport-events&event_type=$1&sport=$2 [L]
RewriteRule ^/?sport-events/([a-zA-Z]+) index.php?menu=sport-events&event_type=$1 [L]
RewriteRule ^/?sport-events index.php?menu=sport-events [L]
RewriteRule ^/?event/([0-9]+) index.php?menu=event&event_id=$1 [L]

RewriteRule ^/?feed	rss.php [L]
RewriteRule ^/?moviefeed	movierss.php [L]
RewriteRule ^/?watch/([a-z0-9-/]+)$ index.php?menu=watchmovie&perma=$1 [L]
RewriteRule ^/?tvtag/([a-z0-9_/]+)$ index.php?menu=tv-tag&tag=$1 [L]
RewriteRule ^/?movietag/([a-z0-9_/]+)$ index.php?menu=movie-tag&tag=$1 [L]
RewriteRule ^/?([a-z0-9-/]+)\.html$ index.php?menu=$1 [L]
RewriteRule ^/?pages/([a-z0-9-/]+) index.php?menu=page&permalink=$1 [L]
RewriteRule ^/?tv-shows/(\d+)$ index.php?menu=tv-shows&p=$1 [L]
RewriteRule ^/?tv-shows index.php?menu=tv-shows [L]
RewriteRule ^/?channel/(\d+)$ index.php?menu=channel&channel_id=$1 [L]
RewriteRule ^/?live-channels index.php?menu=live-channels [L]
RewriteRule ^/?register index.php?menu=register [L]
RewriteRule ^/?logout index.php?menu=logout [L]
RewriteRule ^/?login index.php?menu=login [L]
RewriteRule ^/?home index.php?menu=home [L]
RewriteRule ^/?movies/(\d+)$ index.php?menu=movies&p=$1 [L]
RewriteRule ^/?movies index.php?menu=movies [L]
RewriteRule ^/?([a-zA-Z0-9-]+)/season/([0-9]+)/episode/([0-9]+)$ index.php?menu=episode&perma=$1&season=$2&episode=$3 [L]
RewriteRule ^/?([a-zA-Z0-9-]+)/season/([0-9]+)$ index.php?menu=show&perma=$1&season=$2 [L]
RewriteRule ^/?([a-zA-Z0-9-]+)/feed$ rss.php?perma=$1 [L]
RewriteRule ^/?([a-zA-Z0-9-]+)$ index.php?menu=show&perma=$1 [L]

Would anyone please be so kind to help me out with this simple script :sun:?

Thanks a ton!
 
Last edited:
Status
Not open for further replies.
Back
Top