PDA

View Full Version : Redirects


redsox9
03-16-2006, 04:40 AM
Hi, everybody!

I know that I asked this question back when the forum first went online and then the crash wiped out the well-defined answer.

I want to set up redirects that a request for any file from an old directory points to a file in another location. Example:

http://www.sample.com/dir1/*.* --> http://www.sample.com/dir2/file.html

I know that you have to modify your .htaccess file but would someone just remind me how to handle this situation?... and we thank you for your support. :cool:

piku
03-16-2006, 11:00 AM
Check your cPanel > Redirects. Should give you the solution you're looking for. HTH

vegasgwm
03-16-2006, 11:43 AM
Hi,
I'm using this(below) for redirection. But check with support first. Today, after 2 weeks of it working fine on my site something went wrong. I'm waiting for support to reply to my ticket. Someone suggested somewhere in this forum that there might be rewrite problems on bluehost servers. I hope it's not true, because my whole site depends on url rewrites.

(without the # ofcourse)

#RewriteEngine on

# RewriteCond %{http_host} ^yoursite/olddir$
# RewriteCond %{REQUEST_URI} !^/newdir/
# RewriteRule ^(.*)$ /newdir/$1

i'm not a rewrite expert, if someone sees an error in these lines, please correct it.

DrRx
03-16-2006, 05:12 PM
Hi,
I'm using this(below) for redirection. But check with support first. Today, after 2 weeks of it working fine on my site something went wrong. I'm waiting for support to reply to my ticket. Someone suggested somewhere in this forum that there might be rewrite problems on bluehost servers. I hope it's not true, because my whole site depends on url rewrites.

(without the # ofcourse)

#RewriteEngine on

# RewriteCond %{http_host} ^yoursite/olddir$
# RewriteCond %{REQUEST_URI} !^/newdir/
# RewriteRule ^(.*)$ /newdir/$1

i'm not a rewrite expert, if someone sees an error in these lines, please correct it.

Try below code :confused: (I am not sure that it works or?)

RewriteEngine on
RewriteBase /
RewriteCond %{http_host} yoursite/olddir$
RewriteCond %{REQUEST_URI} !^/newdir/
RewriteRule ^(.*)$ /newdir/$1 [L]

vegasgwm
03-16-2006, 05:38 PM
Thanx DRx,
Just a quick update:
I spoke with support and although they didn't give me a concrete answer it turns out there's nothing wrong with my rewrite code. My site works fine now, with the same code. I don't know if somehow the re-write engine was turned off.

redsox9
03-16-2006, 06:24 PM
Check your cPanel > Redirects. Should give you the solution you're looking for. HTH

Yes, I was aware that there is a Redirect feature on cPanel but I know that, in the past, I had tried doing a "complex" redirect similar to what I had written in my original message. Still, it doesn't hurt to make those people who aren't aware of this featuer if they want to do a simple redirect, i.e.,

http://www.sample.com/old/file/location.html --> http://www.sample.com/new/file/location.php

Vegasgwm and DrRx - does that code go into the .htaccess file? I'm not clear on that. Thanks for the help! :D

DrRx
03-16-2006, 10:36 PM
Yes, I was aware that there is a Redirect feature on cPanel but I know that, in the past, I had tried doing a "complex" redirect similar to what I had written in my original message. Still, it doesn't hurt to make those people who aren't aware of this featuer if they want to do a simple redirect, i.e.,

http://www.sample.com/old/file/location.html --> http://www.sample.com/new/file/location.php

Vegasgwm and DrRx - does that code go into the .htaccess file? I'm not clear on that. Thanks for the help! :D
Yes, those code will produce a ".htaccess" file automatically if you do it with "Check your cPanel > Redirects".