Redirecting a webpage

Dear Experts,

I need to redirect the url:

http://www.narmi2.com/page1.php

to

http://www.narmi2.com/page1.php?id=1

But each time I try, the browser says that it stops executing the page because of a loop.

How do I redirect this?
LVL 1
narmi2Asked:
Who is Participating?
 
bansidharCommented:
if you want to avoid a redirect you can use


if (!isset($_GET['id'])) {$_GET['id']=1;}

Open in new window

0
 
bansidharCommented:
try

RewriteRule   ^page1.php$    /page1.php?id=1     [L]
0
 
ashfoxCommented:
Hello,

Can you not have a php statement where if id="" then:

<html><head>
  <meta http-equiv="Refresh" content="0; url=http://www.narmi2.com/page1.php?id=1">

0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
danirk2Commented:
You can't, the loop is real :
http://www.narmi2.com/page1.php?id=1 will be redirected to http://www.narmi2.com/page1.php?id=1 :)

What you try to acive seems to be that you will get an default parameter "id" for users calling the page without.

You could do this in code (when 'id' is null/empty -> 'id' = "1")
0
 
under_dogCommented:
Or something like this:
<?php
 
  if (!isset($_GET['id'])) { header('location: http://www.narmi2.com/page1.php?id=1'); }
 
?>

Open in new window

0
 
caterham_wwwCommented:
check, if the qs is empty:
RewriteEngine on
RewriteCond %{QUERY_STRING} =""
RewriteRule   ^page1\.php$    /page1.php?id=1     [L]

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.