bs0d |
Subject: "re: Mod rewrite"
Posted: @ 5:10 pm on Aug 20 2006
|
|
|
 Member #: 1 Rank: Admin. - (1,510) Since: 02/06/05 Posts: 604 From: USA
|
Are you trying
to mod rewrite
index.php?page=
contact to
index/contact ?
and
index.php?page=
news&limit=
1&page=4
to
index/news/1/4
?
|
Viewed: 33,562 Times | |  |
AdRock |
Subject: "re: Mod rewrite"
Posted: @ 6:21 pm on Aug 20 2006
|
|
|
Member #: 186 Rank: user - (31) Since: 07/21/06 Posts: 31 From: Devon
|
yes....exactly
what i'm
trying to do
|
Viewed: 33,559 Times | |  |
bs0d |
Subject: "re: Mod rewrite"
Posted: @ 9:18 pm on Aug 20 2006
|
|
|
 Member #: 1 Rank: Admin. - (1,510) Since: 02/06/05 Posts: 604 From: USA
|
try:
Code:
RewriteEngine
on
RewriteBase
/
RewriteRule
^(.*)/
index.php?page=
$1 [NC]
RewriteRule
^(.*)/(.*)/(.*)
/
index.php?page=
$1&limit=$2
&page=$3
[NC]
something like
that...
|
Viewed: 33,555 Times | |  |
AdRock |
Subject: "re: Mod rewrite"
Posted: @ 10:07 pm on Aug 20 2006
|
|
|
Member #: 186 Rank: user - (31) Since: 07/21/06 Posts: 31 From: Devon
|
That didn't
work. Every
time i clicked
a link it would
default to the
home page
(home.php)
This worked but
i couldn't do
any pagination
Options
+FollowSymLinks
RewriteEngine
on
RewriteRule
^index/(.*)
index.php?page=
$1 [L]
I need to add a
rewrite rule
like this to do
the
pagination
has it got
anything to do
with this
switch
($_GET['page'
])
{
case
"change-p
assword":
include('chan
ge-password.php
');
break;
case
"contact
":
include('cont
act.php');
break;
default:
include('home
.php');
}
Edited at 02:49:26 pm on 08/21/06
|
Viewed: 33,552 Times | |  |
AdRock |
Subject: "re: Mod rewrite"
Posted: @ 12:43 am on Aug 22 2006
|
|
|
Member #: 186 Rank: user - (31) Since: 07/21/06 Posts: 31 From: Devon
|
Is this correct
for mod
rewrite
Options
+FollowSymLinks
RewriteEngine
on
RewriteBase
/
RewriteRule
^index/(.*)
index.php?page=
$1 [NC]
RewriteRule
^index/(.*)/(.*
)
index.php?page=
$1&limit=$2
&pagenum=$3
[L]
Can you tell me
how you would
rewrite these
urls used in
your pagination
script becuase
as i understand
it each of the
links within
the pages has
to be in the
same format
such as
http://www.y
oursite.com/stu
ff/php/10/1.php
e.g.
Code:
$prev_page =
$page - 1;
if($prev_page
>= 1) {
echo("<
;b><<&
lt;/b> <a
href=http://www
.yoursite.com/s
tuff/script.php
?cat=$cat&l
imit=$limit&
;page=$prev_pag
e><b>P
rev.</b>&
lt;/a>"
 ;
}
|
Viewed: 33,537 Times | |  |
bs0d |
Subject: "re: Mod rewrite"
Posted: @ 3:42 am on Aug 22 2006
|
|
|
 Member #: 1 Rank: Admin. - (1,510) Since: 02/06/05 Posts: 604 From: USA
|
What you're
doing with
Mod_Rewrite is
making the URL
prettier,
basically. Your
script still
needs the same
parameters, and
they will still
be passed,
except they
will be viewed
differently in
the URL. The
script can
still access
them the same
way. if you
have:
index.php?page=
1&limit=2 ,
then you can
still access
$_GET['page']
and
$_GET['limit'
].
So if you check
out the rewrite
rules, each
"wild-car
d" or
(.*) will be
referenced to
$1, $2 and so
on
respectively.
So in my
pagination this
is basically
the code I use
for displaying
available code
samples
(cat_list.php)
and then
viewing code
samples
(view.php):
Code:
RewriteEngine
on
RewriteBase
/code/
RewriteRule
^(.*)/(.*)/(.*)
\.php$
cat_list.php?ty
pe=$1&limit
=$2&page=$3
[NC]
RewriteRule
^(.*)/(.*)/(.*)
/
view.php?id=$2
[NC]
Now apply that
same concept to
your own
files/directori
es. Any further
questions on
the coding for
it, i'd do a
google search
on regex
Edited at 03:52:16 am on 08/22/06
|
Viewed: 33,531 Times | |  |
AdRock |
Subject: "re: Mod rewrite"
Posted: @ 11:57 pm on Aug 22 2006
|
|
|
Member #: 186 Rank: user - (31) Since: 07/21/06 Posts: 31 From: Devon
|
I got the mod
rewrite working
properly now.
Everywhere I
went said
different
things but I
have one last
question
I have 3 pages
called jack1,
jack2, jack3
and jack4.
How would i
rewrite it so
it reads
/jack/1 etc or
is it not
possible
|
Viewed: 33,523 Times | |  |
bs0d |
Subject: "re: Mod rewrite"
Posted: @ 1:33 am on Aug 23 2006
|
|
|
 Member #: 1 Rank: Admin. - (1,510) Since: 02/06/05 Posts: 604 From: USA
|
well... im sure
its possible. I
dont know the
answer off the
top of my head.
But I will tell
you one thing,
the directories
of Mod_Rewrite
only need to
mach the ID's
from the query
string. The
others (like
title of
article) can be
anything. you
could visit:
/tutorials/php/
15/this_tutoria
l_dont_exist/1.
php and its
going to load
the tutorial
with the id of
15 and page 1,
because the
title does not
matter. You
could put
anything.
So you could do
the same thing
with Jack
|
Viewed: 33,520 Times | |  |
AdRock |
Subject: "re: Mod rewrite"
Posted: @ 12:52 pm on Aug 31 2006
|
|
|
Member #: 186 Rank: user - (31) Since: 07/21/06 Posts: 31 From: Devon
|
I got a weird
problem with
using
$_GET['id']
to get the id
from a
rewritten url.
I have created
a simple image
gallery but
when i click on
a thumbnail,
the page with
the enlarged
image doesn't
display an
image.
Here is my code
which is
causing the
problem
Code:
<?php
include_once(&
quot;includes/c
onnection.php&
quot  ;
$id =
$_GET['id'];<
br />
$query =
"SELECT *
FROM images
WHERE id =
'$id'";
$result =
mysql_query($qu
ery) or
die(mysql_error
());
while ($row =
mysql_fetch_arr
ay($result)) {
echo
"<img
src='/gallery/
".$row['
image']."
;'>";
}
?>
The url looks
like this
http://www.jac
kgodfrey.org.uk
/image/1
When i click on
an image it
opens the above
page code which
is supposed to
open the
enlarged image
but it
doesn't
I think it's
to do with the
$_GET becuase
if i don't mod
rewrite the url
it works
|
Viewed: 33,470 Times | |  |
misterhaan |
Subject: "re: Mod rewrite"
Posted: @ 3:41 pm on Aug 31 2006
|
|
|
 Member #: 5 Rank: Contributor - (214) Since: 02/11/05 Posts: 149 From: chair
|
what does your
rewrite look
like, and what
exactly isn't
working for
you?
please note
that the above
post is likely
made up in its
entirety. |
Viewed: 33,465 Times | |  |
Guest |
Subject: "re: Mod rewrite"
Posted: @ 6:32 pm on Aug 31 2006
|
|
|
Unregistered
|
make sure it
has a .php
extension in
your Rewrite
rule?
|
Viewed: 33,462 Times | |  |
AdRock |
Subject: "re: Mod rewrite"
Posted: @ 12:15 am on Sep 01 2006
|
|
|
Member #: 186 Rank: user - (31) Since: 07/21/06 Posts: 31 From: Devon
|
I found out
what the
problem
is.....there is
a conflict
between 2
rewrite
rules.
The first
rewrite rulle
will always
work but not
the second even
if i switch
them around.
I need them
both to work
RewriteRule
^([A-Za-z0-9]+)
/([0-9]+)/?$
index.php?page=
$1&id=$2
RewriteRule
^([A-Za-z0-9]+)
/([0-9]+)/?$
index.php?page=
$1&pagenum=
$2
|
Viewed: 33,457 Times | |  |
bs0d |
Subject: "re: Mod rewrite"
Posted: @ 12:36 am on Sep 01 2006
|
|
|
 Member #: 1 Rank: Admin. - (1,510) Since: 02/06/05 Posts: 604 From: USA
|
why are you
listing page
twice??
?page=1&pag
enum=2 ... it
dont work like
that, you cant
have 2 rules
for the same
directories. If
you want the
2nd, make your
url's like
this:
index.php?page=
$1&id=$2&am
p;pagenum=$3
RewriteRule
^([A-Za-z0-9]+)
/([0-9]+)/([0-9
]+)?$
index.php?page=
$1&id=$2pag
enum=$3
Edited at 12:40:12 am on 09/01/06
|
Viewed: 33,454 Times | |  |
Viewing Page: 1 of 1 |