> Programming Languages > PHP
Various Topics Home | Disclaimer | Report Adult Posts

Various Topics on PHP



PHP - "mod_rewrite help" in Programming Languages


Old 06-21-2004   #1
....coa.. ..e..
 
Default mod_rewrite help

Hello. How do I do this:

If a visitor types in any number after my url, I want mod_rewrite to
convert it to my url/anotherpage.html?number=number_visitor_typed

Example:

http://www.mysite.com/12345678.html

would result in:

http://www.mysite.com/anotherpage.html?number=12345678

another example:

http://www.mysite.com/000111000.html

would result in:

http://www.mysite.com/anotherpage.html?number=000111000

Thank you.

 
Old 06-21-2004   #2
..cha.. ..st..
 
Default Re: mod_rewrite help

Westcoast Sheri wrote:

> Hello. How do I do this:
>
> If a visitor types in any number after my url, I want mod_rewrite to
> convert it to my url/anotherpage.html?number=number_visitor_typed
>
> Example:
>
> http://www.mysite.com/12345678.html
>
> would result in:
>
> http://www.mysite.com/anotherpage.html?number=12345678
>
> another example:
>
> http://www.mysite.com/000111000.html
>
> would result in:
>
> http://www.mysite.com/anotherpage.html?number=000111000
>
> Thank you.
>



No need to double-post, and this probably belongs in an apache forum.

see: << http://httpd.apache.org/docs-2.0/mod...ml#rewriterule >>
for details in the re-write function.

I am not that good with regexpr so, you may need to experiment with
this...

RewriteRule ^(*\/0-9)\.html$ rewrite.php?file=$1.html

What this means is that you substitute all htmlfiles that have [0-9] and
send them through your rewrite php script. BTW I found this by going to
both the apache and php online manuals and did site searches for
rewrite. These are the resulting pages:

http://www.php.net/imagecreatefrompng
http://httpd.apache.org/docs-2.0/mod...ml#rewriterule

I would consider a front-page with a form for typing the number, then
redirecting from that point.

<? php
///////////////// My standar PHP header for > 2.0

if (!empty($_GET))
{
extract($_GET);
}
else if (!empty($HTTP_GET_VARS))
{
extract($HTTP_GET_VARS);
}

if (!empty($_POST))
{
extract($_POST);
}
else if (!empty($HTTP_POST_VARS))
{
extract($HTTP_POST_VARS);
}
if (isset ($flag))
{ //code to redirect to http://new.site.dom/$number.html
echo '<form method=post><br><center><input TYPE=submit
value=Back></center>';
}
else
{ echo "<form method=post>";
echo "<input type=text name=number> Enter Page Number<br><p>";
echo "<input type=hidden name=flag value=1>";
echo "<input TYPE=submit value=Submit>";
echo "<input TYPE=reset value=Reset>";
echo "</form>";
}

 

Thread Tools
Display Modes





Powered by vBulletin®
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0