howdy guys; scoutt, I spent
good 20mins on that link
from your site and couldn't get any of it
Basicly I need to turn URLs like:
file.php?id=2
into something like...
file.php/id/2
This way I can use this
in a news script I'm making;
It uses the id=$id to find the
post id, and from that get the
poster's email addie.
This is so people can contact
the author of the news post, w/o
people seeing their email address.
This way-- easier to avoid spam you don't have ot use mod_rewrite, I couldn't get it to work either. but I didn't try very hard.
just use php to do it. like it show, PATH_INFOOriginally posted by scoutt
you don't have ot use mod_rewrite, I couldn't get it to work either. but I didn't try very hard.
just use php to do it. like it show, PATH_INFO
erhm...I really don't understand
how would I use that to make
file.php?id=3 into file.php/id/3 ...$var_array = explode("/",$_SERVER['PATH_INFO']);
// for apache to work we need this
//AcceptPathInfo On
if(count($var_array) > 1){
$GET["action"] = $var_array[1];
$GET["id"] = $var_array[2];
}
to do this you have to have AcceptPathInfo On in apache.conf file.
action will be the id and id will = 3
you can also change all that to be $_GET as well. thi sway you don't have to edit a lot of scripts.if I understand this-- it'd make all
'file.php' documents be same as
having 'file.php?id=3' ??
I don't need that; I just showed
that as example; need to make the URL
more search-engine friendly well you have to code for it, you can't use links tha tset it as ?id=2 you have to use id/3 for now on.
look at <!-- w --><a class="postlink" href="http://www.boxedart.com">www.boxedart.com</a><!-- w -->, see how the links are set?yea,
<!-- m --><a class="postlink" href="http://www.boxedart.com/phpshop/article.php/view/0/11/75">http://www.boxedart.com/phpshop/article ... ew/0/11/75</a><!-- m -->
Isn't that mod rewrite??nope, I use exactly as I have shown hereI still don't understand this
My head hurts ok, you're thinking to hard on this
I have this code being loaded on every page
$var_array = explode("/",$_SERVER['PATH_INFO']);
// for apache to work we need this
//AcceptPathInfo On
if(count($var_array) > 1){
$GET["action"] = $var_array[1];
$GET["id"] = $var_array[2];
}
then in th page I have something like this
<a href=http://www.htmlforums.com/archive/index.php/"site.com/page.php/$GET["action"]/$GET["id"]">
but instead of the $GET["id"] I would have something generated but php that shows the next ID or a different ID, eitehr way it is a number.
that is all. is that easier?an example .htaccess file
RewriteEngine On
RewriteRule ^file/(.*).html file.php?id=$1
that would make it so isntead of going to file.php?id=1, you could go to file/1.html and it would be the same. you could actually take out the .html altogether if you wanted.OOoOoOoOoO now that I see that URL
scout-- muuch easiler to see where your going
Also n8th, could I do that except
replace $1 with $id so its automatic?
Also how would I take out the .HTML??the $1 just refers to the mod rewrite regular expression, not a php variable
to take out the .html, you just...not have a .html on the end of the expression the $1 is a variable, it gets whatever is in the (.*) as the file name.RewriteEngine On
RewriteRule ^file/(.*).php index.php?id=$1
Now I put in the same folder
as my script and try...
index.php/1 ~ instead of ~ index.php?id=1
No work
And index/1.php didn't work either you have to cahnge the "file" at the beginning of the regular expression and get rid of the .php
and you dont do index.php/1, if you changed the "file" at the beginning to "index" it would be just index/1, no extension.except for fact when navigating,
I noticed after I kept checking
between the three 'test' files--
it "built" the URL up like this...
<!-- m --><a class="postlink" href="http://labs.gamerdesigns.com/modrewrite/index/index/index/index/index/1">http://labs.gamerdesigns.com/modrewrite ... ex/index/1</a><!-- m -->
Otherwise it works fixed
was using URL in the link-
index/1
should've been this URL-
/modrewrite/index/1hiya all back again
Okay, I want to take a URL like...
index.php?style=hitech&page=home
And make it into....
index/hitech/home
How would I use MOD REWRITE for that?
the other code (obviously) wouldn't
work and thats all I can understand
about MOD REWRITE * n00bish bump *sorry, I don't use mod_rewrite as it is a lot harder. my way doesn't require all that messing around with mod-rewrite.
so what do you have now?turning index.php?style=gamer&page=home
into index/gamer/home
I tried your way, couldn't get it
I am getting a book that talks of
"making shorter URLs", but I'm 2impatient
to wait for it to get here what is in the htaccess file is what I meant. my way you hav eot have a setting in apache turned on, most do but some don't.
good 20mins on that link
from your site and couldn't get any of it
Basicly I need to turn URLs like:
file.php?id=2
into something like...
file.php/id/2
This way I can use this
in a news script I'm making;
It uses the id=$id to find the
post id, and from that get the
poster's email addie.
This is so people can contact
the author of the news post, w/o
people seeing their email address.
This way-- easier to avoid spam you don't have ot use mod_rewrite, I couldn't get it to work either. but I didn't try very hard.
just use php to do it. like it show, PATH_INFOOriginally posted by scoutt
you don't have ot use mod_rewrite, I couldn't get it to work either. but I didn't try very hard.
just use php to do it. like it show, PATH_INFO
erhm...I really don't understand
how would I use that to make
file.php?id=3 into file.php/id/3 ...$var_array = explode("/",$_SERVER['PATH_INFO']);
// for apache to work we need this
//AcceptPathInfo On
if(count($var_array) > 1){
$GET["action"] = $var_array[1];
$GET["id"] = $var_array[2];
}
to do this you have to have AcceptPathInfo On in apache.conf file.
action will be the id and id will = 3
you can also change all that to be $_GET as well. thi sway you don't have to edit a lot of scripts.if I understand this-- it'd make all
'file.php' documents be same as
having 'file.php?id=3' ??
I don't need that; I just showed
that as example; need to make the URL
more search-engine friendly well you have to code for it, you can't use links tha tset it as ?id=2 you have to use id/3 for now on.
look at <!-- w --><a class="postlink" href="http://www.boxedart.com">www.boxedart.com</a><!-- w -->, see how the links are set?yea,
<!-- m --><a class="postlink" href="http://www.boxedart.com/phpshop/article.php/view/0/11/75">http://www.boxedart.com/phpshop/article ... ew/0/11/75</a><!-- m -->
Isn't that mod rewrite??nope, I use exactly as I have shown hereI still don't understand this
My head hurts ok, you're thinking to hard on this
I have this code being loaded on every page
$var_array = explode("/",$_SERVER['PATH_INFO']);
// for apache to work we need this
//AcceptPathInfo On
if(count($var_array) > 1){
$GET["action"] = $var_array[1];
$GET["id"] = $var_array[2];
}
then in th page I have something like this
<a href=http://www.htmlforums.com/archive/index.php/"site.com/page.php/$GET["action"]/$GET["id"]">
but instead of the $GET["id"] I would have something generated but php that shows the next ID or a different ID, eitehr way it is a number.
that is all. is that easier?an example .htaccess file
RewriteEngine On
RewriteRule ^file/(.*).html file.php?id=$1
that would make it so isntead of going to file.php?id=1, you could go to file/1.html and it would be the same. you could actually take out the .html altogether if you wanted.OOoOoOoOoO now that I see that URL
scout-- muuch easiler to see where your going
Also n8th, could I do that except
replace $1 with $id so its automatic?
Also how would I take out the .HTML??the $1 just refers to the mod rewrite regular expression, not a php variable
to take out the .html, you just...not have a .html on the end of the expression the $1 is a variable, it gets whatever is in the (.*) as the file name.RewriteEngine On
RewriteRule ^file/(.*).php index.php?id=$1
Now I put in the same folder
as my script and try...
index.php/1 ~ instead of ~ index.php?id=1
No work
And index/1.php didn't work either you have to cahnge the "file" at the beginning of the regular expression and get rid of the .php
and you dont do index.php/1, if you changed the "file" at the beginning to "index" it would be just index/1, no extension.except for fact when navigating,
I noticed after I kept checking
between the three 'test' files--
it "built" the URL up like this...
<!-- m --><a class="postlink" href="http://labs.gamerdesigns.com/modrewrite/index/index/index/index/index/1">http://labs.gamerdesigns.com/modrewrite ... ex/index/1</a><!-- m -->
Otherwise it works fixed
was using URL in the link-
index/1
should've been this URL-
/modrewrite/index/1hiya all back again
Okay, I want to take a URL like...
index.php?style=hitech&page=home
And make it into....
index/hitech/home
How would I use MOD REWRITE for that?
the other code (obviously) wouldn't
work and thats all I can understand
about MOD REWRITE * n00bish bump *sorry, I don't use mod_rewrite as it is a lot harder. my way doesn't require all that messing around with mod-rewrite.
so what do you have now?turning index.php?style=gamer&page=home
into index/gamer/home
I tried your way, couldn't get it
I am getting a book that talks of
"making shorter URLs", but I'm 2impatient
to wait for it to get here what is in the htaccess file is what I meant. my way you hav eot have a setting in apache turned on, most do but some don't.