Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Ezilon Directory   Improve your ranking, submit to directories   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 03-22-2004, 07:51 PM   #1 (permalink)
Moderator
 
LazyJim's Avatar
 
Join Date: 10-13-03
Location: UK
Posts: 2,819
iTrader: 0 / 0%
Latest Blog:
None

LazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to all
Send a message via MSN to LazyJim
php rewrite?

Ok my site is all on one page index.php, and it has ?query string (_GET) variables to navigate,
e.g. ?section=contact
e.g. ?section=about&page=services

This works fine, but now I decided I want directory structures to work as well,
e.g. /contact/
e.g. /about/services/

I can use PHP to re-write the directory names to _GET variables in the ?query string, and I can redirect the browser to the new URL with a header( "refresh: 0; url=$rewritten_url"); statement.
But then the re-written URL shows up in the browser.

I want to use header("location:$rewritten_url");, but for some reason it isn't working!

Here's the script I'm using, can anyone see why?

[code:1:21a609892e]<?php
$sOldPath = trim($_SERVER['REQUEST_URI']);
/* TODO: get rid of .html .php etc */
$aParts = preg_split("/[\/]+/", $sOldPath, -1, PREG_SPLIT_NO_EMPTY);
$sNewPath = "";
switch (count(array_slice($aParts,0,2))) {
case 2: $sNewPath = "&page=" . $aParts[1];
case 1: $sNewPath = "?section=" . $aParts[0] . $sNewPath;
}
$sNewPath = 'Location:http://' . $_SERVER['HTTP_HOST'] . '/index.php' . $sNewPath;
Header($sNewPath);
exit();
?>
[/code:1:21a609892e]
__________________

-LJ-

My advice is to look at each case individually, with an informed mind and an appropriately balanced and objective viewpoint.

Web Design and Development, Ipswich, UK.
My deviantArt
LazyJim is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 03-22-2004, 07:58 PM   #2 (permalink)
Moderator
 
LazyJim's Avatar
 
Join Date: 10-13-03
Location: UK
Posts: 2,819
iTrader: 0 / 0%
Latest Blog:
None

LazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to all
Send a message via MSN to LazyJim
Oh yeah, and this script run with .htaccess ErrorDocument 404 directive.

Or does Location: redirect change the visible address too??
__________________

-LJ-

My advice is to look at each case individually, with an informed mind and an appropriately balanced and objective viewpoint.

Web Design and Development, Ipswich, UK.
My deviantArt
LazyJim is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-22-2004, 07:59 PM   #3 (permalink)
Moderator
 
LazyJim's Avatar
 
Join Date: 10-13-03
Location: UK
Posts: 2,819
iTrader: 0 / 0%
Latest Blog:
None

LazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to all
Send a message via MSN to LazyJim
i suppose I could make index.php my ErrorDocument, but the redirect not working really bugs me!
__________________

-LJ-

My advice is to look at each case individually, with an informed mind and an appropriately balanced and objective viewpoint.

Web Design and Development, Ipswich, UK.
My deviantArt
LazyJim is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-22-2004, 08:12 PM   #4 (permalink)
Moderator
 
LazyJim's Avatar
 
Join Date: 10-13-03
Location: UK
Posts: 2,819
iTrader: 0 / 0%
Latest Blog:
None

LazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to all
Send a message via MSN to LazyJim
Well I fixec my index.php to convert the directory based nav to the ?query based one it was already using, and changed my 404 ErrorDocument to index.php.

It works: http://www.alpha-matrix-design.co.uk/about/services/
__________________

-LJ-

My advice is to look at each case individually, with an informed mind and an appropriately balanced and objective viewpoint.

Web Design and Development, Ipswich, UK.
My deviantArt
LazyJim is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-22-2004, 08:13 PM   #5 (permalink)
Moderator
 
LazyJim's Avatar
 
Join Date: 10-13-03
Location: UK
Posts: 2,819
iTrader: 0 / 0%
Latest Blog:
None

LazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to all
Send a message via MSN to LazyJim
And this way it needs a <base href=""> elemtent before any external files are linked in the HTML (images, javascripts, css files, movies etc).

well thanks for ya help LJ!
__________________

-LJ-

My advice is to look at each case individually, with an informed mind and an appropriately balanced and objective viewpoint.

Web Design and Development, Ipswich, UK.
My deviantArt
LazyJim is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-23-2004, 05:41 AM   #6 (permalink)
No Longer Here
 
Join Date: 09-27-03
Location: State College, PA
Posts: 9,354
iTrader: 0 / 0%
Latest Blog:
None

Jazzee is liked by somebodyJazzee is liked by somebodyJazzee is liked by somebodyJazzee is liked by somebodyJazzee is liked by somebody
No problem
Jazzee is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-23-2004, 09:21 AM   #7 (permalink)
Moderator
 
LazyJim's Avatar
 
Join Date: 10-13-03
Location: UK
Posts: 2,819
iTrader: 0 / 0%
Latest Blog:
None

LazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to all
Send a message via MSN to LazyJim
__________________

-LJ-

My advice is to look at each case individually, with an informed mind and an appropriately balanced and objective viewpoint.

Web Design and Development, Ipswich, UK.
My deviantArt
LazyJim is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-01-2004, 12:21 AM   #8 (permalink)
Inactive
 
Join Date: 10-22-03
Location: Bali Island
Posts: 27
iTrader: 0 / 0%
Latest Blog:
None

putu is liked by many
use .htaccess mod_rawrite ?
putu is offline  
Add Post to del.icio.us
Reply With Quote
Old 04-01-2004, 03:37 AM   #9 (permalink)
Moderator
 
LazyJim's Avatar
 
Join Date: 10-13-03
Location: UK
Posts: 2,819
iTrader: 0 / 0%
Latest Blog:
None

LazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to allLazyJim is a name known to all
Send a message via MSN to LazyJim
Using PHP I can do searches on my site too, rather than just fling them at a page.
Plus I don't have to play with funny reg-ex patterns that not many ppl understand very well.
__________________

-LJ-

My advice is to look at each case individually, with an informed mind and an appropriately balanced and objective viewpoint.

Web Design and Development, Ipswich, UK.
My deviantArt
LazyJim is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
301 asp rewrite? bomy Coding Forum 10 06-19-2007 02:05 AM
Mod Rewrite Help...please DM_Web _Directory Coding Forum 16 04-11-2007 06:43 PM
How to do rewrite like v7n Antonio Coding Forum 3 04-01-2006 04:19 AM
need help with mod rewrite url rewrite sim Coding Forum 3 07-31-2005 06:51 PM
Mod Rewrite T-Kai Coding Forum 5 08-24-2004 10:42 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 02:14 PM.
© Copyright 2008 V7 Inc