By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,348 Members | 1,397 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,348 IT Pros & Developers. It's quick & easy.

mod_rewrite help

P: n/a
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.

Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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>";
}

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.