How to redirect index page?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ljCharlie
Forum Contributor
Posts: 289
Joined: Wed May 19, 2004 8:23 am

How to redirect index page?

Post by ljCharlie »

Here's what I'm trying to do. When people type in http://www.mysite.com/enewsletter/ in the URL, the browser will load the index.php page by default. But what I wanted to do is when people type this, http://www.mysite.com/enewsletter/, in the URL I want the browser to load http://www.mysite.com/enewsletter/enews.php?id=1. Can this be done? If yes, mind showing me the steps?

Thanks!
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

mean you want the browser to redirect do you? Or simply load the page as if that were in the URL you want?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

search these forums for mod_rewrite
ljCharlie
Forum Contributor
Posts: 289
Joined: Wed May 19, 2004 8:23 am

Post by ljCharlie »

Yes, that is what I want. I want the browser simply load the page as if that were in the URL. Can this be done?

And yes, I will search for mod_rewrite. I hope it's not too difficult.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Are you using Apache?
ljCharlie
Forum Contributor
Posts: 289
Joined: Wed May 19, 2004 8:23 am

Post by ljCharlie »

Many thanks for your help. Yes, I think I'm using an Apache but I'm not the web server administrator. Any I found that this:

Code: Select all

if (!isset($_GET['id'])) {
header ("Location: index.php?id=1");
}


works on my case.
Post Reply