There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Software Development
Tag Cloud
audio blue screen boot bsod computer cpu crash dell desktop driver drivers error excel external hard drive firefox freezes freezing hard drive hardware hijackthis internet internet explorer itunes laptop mac malware motherboard mouse network networking outlook 2007 power printer problem ram router screen slow sound trojan usb virus vista vista 32-bit windows windows vista windows xp winxp wireless wmp
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Redirecting foo.com/something to foo.com/something/


Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
tehon3299's Avatar
Senior Member with 210 posts.
 
Join Date: Mar 2003
Location: Liverpool, NY
03-Feb-2004, 12:19 AM #1
Question Redirecting foo.com/something to foo.com/something/
OK Guys -

HELP! I need to know how I would redirect something on my webpage from www.something.com/gallery to www.something.com/gallery/. If I do not put the last / on the end, it will not go to the page. How can I do this?!! I am running Mandrake 9.2 with Apache 2.

Thanks!
brendandonhu's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
03-Feb-2004, 05:48 PM #2
Heres a quick-n-easy way.

Create a file called ".htaccess".
Put this in it
Code:
<Files gallery>
ForceType application/x-httpd-php
</Files>
Then create a file called "gallery" and put this in it. Make sure there are no blank lines at the beginning or end of the file.

PHP Code:
<?php header('Location: http://yourwebsite.com/gallery/'); ?>
brendandonhu's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
03-Feb-2004, 05:50 PM #3
BTW that requires that you have PHP installed as an Apache Module. If not, look into using mod_rewrite to rewrite the URLs.
Gibble's Avatar
Distinguished Member with 27,137 posts.
 
Join Date: Oct 2001
Location: Striking or Scoring
Experience: The Alpha and Omega
03-Feb-2004, 05:56 PM #4
use the .htaccess file and mod_rewrite so it's done properly

Read here http://www.webmasterworld.com/forum92/82.htm
tehon3299's Avatar
Senior Member with 210 posts.
 
Join Date: Mar 2003
Location: Liverpool, NY
03-Feb-2004, 06:00 PM #5
ALright! Thanks guys!
tehon3299's Avatar
Senior Member with 210 posts.
 
Join Date: Mar 2003
Location: Liverpool, NY
03-Feb-2004, 08:21 PM #6
OK Guys -

I've read the Apache tutorial about the rewrite rules and it says to add:
RewriteEngine on
RewriteBase /~quux/
RewriteRule ^foo$ foo/ [R]

I am running Apache on Linux so would I add:

RewriteEngine on
RewriteBase /var/www/html/
RewriteRule ^gallery$ gallery/ [R]

And where does this go?! I thought it went in my .htaccess file but it doesn't seem to work. Also, should my .htaccess file be in my /var/www/html/ directory?

Thanks!
Gibble's Avatar
Distinguished Member with 27,137 posts.
 
Join Date: Oct 2001
Location: Striking or Scoring
Experience: The Alpha and Omega
03-Feb-2004, 10:22 PM #7
I don't think you need the RewriteBase directive in this case.

And I don't think you would use tje [atj upi are isomg amujpw/
Gibble's Avatar
Distinguished Member with 27,137 posts.
 
Join Date: Oct 2001
Location: Striking or Scoring
Experience: The Alpha and Omega
03-Feb-2004, 10:26 PM #8
Umm...let me try and figure out what I meant to write there!

"And I don't think you would use the path you are using anyhow."

hehe, had my hand on the wrong keys somehow!
tehon3299's Avatar
Senior Member with 210 posts.
 
Join Date: Mar 2003
Location: Liverpool, NY
03-Feb-2004, 11:15 PM #9
Quote:
Originally posted by brendandonhu:

Then create a file called "gallery" and put this in it. Make sure there are no blank lines at the beginning or end of the file.

PHP Code:
<?php header('Location:[url]http://yourwebsite.com/gallery/[/url]');?>
OK...This works if I go to: http://www.mysite.com/gallery.php but if I go to http://www.mysite.com/gallery it just says page not found. Ahh! I cant figure this out! Damn trailing slashes!

EDIT: I cant get that href stuff to go away but I didnt put that in my gallery page anyways.
Gibble's Avatar
Distinguished Member with 27,137 posts.
 
Join Date: Oct 2001
Location: Striking or Scoring
Experience: The Alpha and Omega
03-Feb-2004, 11:24 PM #10
rename gallery.php to just gallery with no extension
tehon3299's Avatar
Senior Member with 210 posts.
 
Join Date: Mar 2003
Location: Liverpool, NY
03-Feb-2004, 11:29 PM #11
It wont let me because I already have a folder named gallery in my root html folder.
Gibble's Avatar
Distinguished Member with 27,137 posts.
 
Join Date: Oct 2001
Location: Striking or Scoring
Experience: The Alpha and Omega
04-Feb-2004, 10:57 AM #12
And that is why you should do it with mod_rewrite
tehon3299's Avatar
Senior Member with 210 posts.
 
Join Date: Mar 2003
Location: Liverpool, NY
04-Feb-2004, 01:10 PM #13
OK...Does this mod_rewrite stuff go in the actually php file or should it be going in my .htaccess file?
Gibble's Avatar
Distinguished Member with 27,137 posts.
 
Join Date: Oct 2001
Location: Striking or Scoring
Experience: The Alpha and Omega
04-Feb-2004, 01:18 PM #14
In the .htaccess file, and you don't need a gallery.php file
Toddles18's Avatar
Distinguished Member with 2,920 posts.
 
Join Date: Jul 2001
Location: Bay City, Michigan
Experience: Level IV Geek
04-Feb-2004, 11:31 PM #15
PHP Code:
html
<
head
<
title>redirect</title
<
meta HTTP-EQUIV="Refresh" CONTENT="0";URL="http://address.com"
</
head
<
body></body
</
html
That works and is easy, though some argue against it because of search engines.
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 08:26 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.