Redirect PHP page with attributes

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
cdickson
Forum Contributor
Posts: 120
Joined: Mon Apr 05, 2004 1:30 pm
Location: Michigan, USA

Redirect PHP page with attributes

Post by cdickson »

Is there any way to redirect a PHP page with attributes?

I'm trying to redirect index.php to index.php?level=slideshow&mode=album&id=1 using the .htaccess file, but it isn't working.

The trouble could be in my syntax, but I'm wondering if it won't work because the page is really redirecting to itself, just with attributes added.

One of the many redirects I've attempted:

Code: Select all

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^www.domain.com/gallery/index.php [nc]
rewriterule ^(.*)$ http://www.domain.com/gallery/index.php?level=slideshow&mode=album&id=1$1 [r=301,nc]
I also tried:

Code: Select all

RewriteEngine  on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE}  [NC]
RewriteRule ^http://www\.domain\.com/gallery/index\.php$  [L]

RewriteCond %{HTTP_USER_AGENT}  ^Mozilla/[345].*Gecko*
RewriteRule ^http://nickwhite\.server319\.com/gallery/index\.php$ http://www.domain.com/gallery/index.php?level=slideshow&mode=album&id=1 [L]

RewriteCond %{HTTP_USER_AGENT}  ^Mozilla/[345].*MSIE*
RewriteRule ^http://nickwhite\.server319\.com/gallery/index\.php$ http://www.domain.com/gallery/index.php?level=slideshow&mode=album&id=1 [L]
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

how does this go...?

Code: Select all

if(count($_GET) == 0)
 header('Location: index.php?level=slideshow&mode=album&id=1');
cdickson
Forum Contributor
Posts: 120
Joined: Mon Apr 05, 2004 1:30 pm
Location: Michigan, USA

Post by cdickson »

Thanks n00b Saibot! Works perfectly.
Post Reply