Connecting Tech Pros Worldwide Help | Site Map

mod_rewrite help

Westcoast Sheri
Guest
 
Posts: n/a
#1: Jul 17 '05
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.

Michael Austin
Guest
 
Posts: n/a
#2: Jul 17 '05

re: mod_rewrite help


Westcoast Sheri wrote:
[color=blue]
> 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.
>[/color]


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>";
}

Closed Thread