Is there a way to redirect pages?
Moderator: General Moderators
Is there a way to redirect pages?
I was wondering if there is a way to redirect pages. For example, I have the following pages:
page1.php
page2.php
page3.php
When people typed in or link from other pages to the following:
http://www.mydomain.com/page1.php, I want to redirect to mypage.php?id=1
http://www.mydomain.com/page2.php, I want to redirect to mypage.php?id=2
http://www.mydomain.com/page3.php, I want to redirect to mypage.php?id=3
Is this possible?
page1.php
page2.php
page3.php
When people typed in or link from other pages to the following:
http://www.mydomain.com/page1.php, I want to redirect to mypage.php?id=1
http://www.mydomain.com/page2.php, I want to redirect to mypage.php?id=2
http://www.mydomain.com/page3.php, I want to redirect to mypage.php?id=3
Is this possible?
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
well you can do a few things. you could do a mod rewrite (i think but i have never done one so i don't know for sure) and you can do this (the easy way)!
EDIT: sorry I read that backwards as you can tell. Mod Rewrite is what you are looking for.
Code: Select all
switch ($_GET['id'])
{
case 1:
header("Location: http://www.website.com/page1.php");
break;
case 2:
header("Location: http://www.website.com/page2.php");
break;
case 3:
header("Location: http://www.website.com/page3.php");
break;
case 4:
header("Location: http://www.website.com/page4.php");
break;
}Okay. I'm looking at my web folder and I do see the .htaccess file. I open this up and saw this:
ErrorDocument 404 /errors/404.php?emailaddress=myemail@mydomain.com
Is this mean I can use .htaccess to redirect missing pages to other current pages? If so, how do I do it? Resource?
ErrorDocument 404 /errors/404.php?emailaddress=myemail@mydomain.com
Is this mean I can use .htaccess to redirect missing pages to other current pages? If so, how do I do it? Resource?
Okay, here's what I tried.
RewriteEngin On
RewriteBase /
RewriteRule ^scholarships\.php$ foundAll.php?id=1
The error is:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, myAdmin@mydomain.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Apache/2.0.54 (Win32) PHP/5.0.4 Server at http://www.mydomain.com Port 80
RewriteEngin On
RewriteBase /
RewriteRule ^scholarships\.php$ foundAll.php?id=1
The error is:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, myAdmin@mydomain.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Apache/2.0.54 (Win32) PHP/5.0.4 Server at http://www.mydomain.com Port 80
- R4000
- Forum Contributor
- Posts: 168
- Joined: Wed Mar 08, 2006 12:50 pm
- Location: Cambridge, United Kingdom
Can't remember off by heart.
But i'm 99% sure this should work for you:
That should make any of the following pages goto the corrosponding url (NOT A VISIBLE REDIRECT, user will still think he is on page*.php)
I suggest you use something like:
This will make something like this happen:
I hope this helsp you.
But i'm 99% sure this should work for you:
Code: Select all
RewriteEngine on
RewriteRule ^page([0-9]).php$ mypage.php?page=$1Code: Select all
page0.php -> mypage.php?page=0
page1.php -> mypage.php?page=1
page2.php -> mypage.php?page=2
page3.php -> mypage.php?page=3
page4.php -> mypage.php?page=4
page5.php -> mypage.php?page=5
page6.php -> mypage.php?page=6
page7.php -> mypage.php?page=7
page8.php -> mypage.php?page=8
page9.php -> mypage.php?page=9Code: Select all
RewriteEngine on
RewriteRule ^pages/(.*).php/$ mypage.php?page=$1Code: Select all
/scripts/purchase.php -> mypage.php?page=purchase
/scripts/download.php -> mypage.php?page=download
/scripts/adminlogin.php -> mypage.php?page=adminlogin.phpI hope this helsp you.
- R4000
- Forum Contributor
- Posts: 168
- Joined: Wed Mar 08, 2006 12:50 pm
- Location: Cambridge, United Kingdom
It could be a sign that it is disabled.
Your only other bet is to create a php file for every page and whack:
Your only other bet is to create a php file for every page and whack:
Code: Select all
<?php
$PAGE_NAME = ""; // This can be replaced with some code to auto get it, forgot the code tho.
header("Location: ../mypage.php?page=".$PAGE_NAME);
?>- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
might be worth it to ask your host if they have mod_rewrite on, or if you php supports it, you can interogate Apache yourself: apache_get_modules()