• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 293
  • Last Modified:

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?
0
narmi2
Asked:
narmi2
5 Solutions
 
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
 
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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
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
 
bansidharCommented:
if you want to avoid a redirect you can use


if (!isset($_GET['id'])) {$_GET['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

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now