Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-21-2006, 03:59 AM   PM User | #1
thesavior
Senior Coder

 
Join Date: Aug 2005
Posts: 1,119
Thanks: 2
Thanked 1 Time in 1 Post
thesavior has a little shameless behaviour in the past
Another simple url rewrite

I want to turn articles/4.html into news.php?id=4

Any ideas?
thesavior is offline   Reply With Quote
Old 08-22-2006, 07:11 AM   PM User | #2
thesavior
Senior Coder

 
Join Date: Aug 2005
Posts: 1,119
Thanks: 2
Thanked 1 Time in 1 Post
thesavior has a little shameless behaviour in the past
*bump*
thesavior is offline   Reply With Quote
Old 08-24-2006, 02:05 AM   PM User | #3
thesavior
Senior Coder

 
Join Date: Aug 2005
Posts: 1,119
Thanks: 2
Thanked 1 Time in 1 Post
thesavior has a little shameless behaviour in the past
*bump*
thesavior is offline   Reply With Quote
Old 08-30-2006, 01:41 AM   PM User | #4
thesavior
Senior Coder

 
Join Date: Aug 2005
Posts: 1,119
Thanks: 2
Thanked 1 Time in 1 Post
thesavior has a little shameless behaviour in the past
any ideas how to do this?
thesavior is offline   Reply With Quote
Old 08-30-2006, 05:55 AM   PM User | #5
Rappa
Regular Coder

 
Rappa's Avatar
 
Join Date: Nov 2005
Location: LI
Posts: 356
Thanks: 21
Thanked 9 Times in 9 Posts
Rappa is an unknown quantity at this point
Code:
<?PHP
switch($id) 
{
default:
echo "this is the default page";
case '4:
echo "put '4' content here";
break;
break;
}
?>

Last edited by Rappa; 08-30-2006 at 05:59 AM..
Rappa is offline   Reply With Quote
Old 08-30-2006, 06:10 AM   PM User | #6
thesavior
Senior Coder

 
Join Date: Aug 2005
Posts: 1,119
Thanks: 2
Thanked 1 Time in 1 Post
thesavior has a little shameless behaviour in the past
What? That is NOT an htaccess rewrite. If you missed the first post, i will repeat it.

I want a user to be able to put articles/4.html in their browser and it to be parsed by the server as news.php?id=4

I don't need to know how to display different material according to the id #. Using htaccess rewrite methods only, how do I do this?
thesavior is offline   Reply With Quote
Old 08-31-2006, 08:20 PM   PM User | #7
thesavior
Senior Coder

 
Join Date: Aug 2005
Posts: 1,119
Thanks: 2
Thanked 1 Time in 1 Post
thesavior has a little shameless behaviour in the past
does anyone know how to do this?
thesavior is offline   Reply With Quote
Old 09-02-2006, 09:32 PM   PM User | #8
thesavior
Senior Coder

 
Join Date: Aug 2005
Posts: 1,119
Thanks: 2
Thanked 1 Time in 1 Post
thesavior has a little shameless behaviour in the past
*bump*
thesavior is offline   Reply With Quote
Old 09-02-2006, 11:34 PM   PM User | #9
googleit
Regular Coder

 
googleit's Avatar
 
Join Date: Jul 2006
Location: birmingham, uk
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
googleit is an unknown quantity at this point
you cant do that with .htacces try this though
PHP Code:
<?php
$action 
$_GET['page'];

function 
yourfilename() {
include(
"yourfilename");
}
if (
$page == "yourfilename") {
yourfilename();
}
?>
then you can make a link like index.php?page=yourfile
and it will display you file on the page
googleit is offline   Reply With Quote
Old 09-03-2006, 12:02 AM   PM User | #10
thesavior
Senior Coder

 
Join Date: Aug 2005
Posts: 1,119
Thanks: 2
Thanked 1 Time in 1 Post
thesavior has a little shameless behaviour in the past
So why wouldn't something like this work?

RewriteRule ^articles/(.*).html$ news.php?id=$1 [L]

That should work but there is a syntax error in there somewhere and I don't know what is wrong.


*edit*

Actually, this does work. View: http://image-space.net/articles/4.html and http://image-space.net/profile/news.php?id=4

Last edited by thesavior; 09-03-2006 at 12:05 AM..
thesavior is offline   Reply With Quote
Old 09-03-2006, 12:29 PM   PM User | #11
googleit
Regular Coder

 
googleit's Avatar
 
Join Date: Jul 2006
Location: birmingham, uk
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
googleit is an unknown quantity at this point
if you knew how to do it y post a thread onit?
googleit is offline   Reply With Quote
Old 09-03-2006, 02:40 PM   PM User | #12
GJay
Senior Coder

 
Join Date: Sep 2005
Posts: 1,791
Thanks: 5
Thanked 36 Times in 35 Posts
GJay is on a distinguished road
Quote:
Originally Posted by googleit
you cant do that with .htacces try this though
yes, you can.
GJay is offline   Reply With Quote
Old 09-03-2006, 04:55 PM   PM User | #13
googleit
Regular Coder

 
googleit's Avatar
 
Join Date: Jul 2006
Location: birmingham, uk
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
googleit is an unknown quantity at this point
k my bad
googleit is offline   Reply With Quote
Old 09-03-2006, 06:24 PM   PM User | #14
thesavior
Senior Coder

 
Join Date: Aug 2005
Posts: 1,119
Thanks: 2
Thanked 1 Time in 1 Post
thesavior has a little shameless behaviour in the past
i just came up with that. I didn't know it at the begining of this thread
thesavior is offline   Reply With Quote
Old 09-03-2006, 10:57 PM   PM User | #15
GJay
Senior Coder

 
Join Date: Sep 2005
Posts: 1,791
Thanks: 5
Thanked 36 Times in 35 Posts
GJay is on a distinguished road
the . probably needs to be escaped...
GJay is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:11 PM.


Advertisement
Log in to turn off these ads.