.htaccess and redirecting
I dont know if this is already posted on this forum before, but i saw it on another forum somewhere, but i didn't understand it verry wel. So if somebody could explain that would help alot.
Here is the situation:
if somebody goes to mydomain.com/name (for example mydomain.com/puttie) then the script has to redirect the user to mydomain.com/userpage.php?username=name (for example mydomain.com/userpage.php?username=puttie)
I think this has to be done with .htaccess, but i dont know how.
Thanks in advance
Suzanne posted this at 18:27 — 14th May 2001.
She has: 5,507 posts
Joined: Feb 2000
It can be done with tags as well, but not invisibly to the user.
Where 60 is the number of seconds until the page refreshes, and URL=http://www.whatever.com/page.html is the page -- no spaces, no quotes, URL must be in all caps.
However, what you want to do for a permanent redirect is:
RedirectPermanent index2.html http://www.zerocattle.com/index.html
Where index2.html is the page you want people to not go to and http://www.zerocattle.com/index.html is the page you want them to see instead. The full url is required for the new page, where as the path is required for the old one.
For temporary redirect using the same files:
RedirectTemp index2.html http://www.zerocattle.com/index.html
***
http://www.wdvl.com/ is an excellent resource, btw, for things like this when you can't bear to go through the Apache documentation at apache.org . They didn't have the information (that I could find) on .htaccess for permanent redirects, however.
http://www.apache.org/DELETE_ME/mod/directives.html has all the information, but it can be a bit confusing without real life examples.
Rob Pengelly posted this at 02:48 — 21st May 2001.
They have: 850 posts
Joined: Jul 1999
Haven't posted here in a while, nor do I plan to, but I just implemented something similiar on my site.
I use my 404 page to redirect users. If someone, for instance goes to
http://www.ratemymullet.com/62
the 'missing.php' will be executed, and inside that file, I redirect the user to
http://www.ratemymullet.com/show.php?id=62
Eg:
<?
//missing.php
$REQUEST_URI = str_replace("/","",$REQUEST_URI);
header("Location: http://www.ratemymullet.com/show.php?id=$REQUEST_URI");
exit;
?>
In your .htaccess file, just add
ErrorDocument 404 /missing.php
In regards to speed, I haven't noticed any speed decreases while using the 404 redirection.
Hope that helps.
http://www.thehungersite.com - http://www.therainforestsite.com
http://www.ratemymullet.com - Beauty is only mullet deep.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.