Page 1 of 1
using MOD_REWRITE to change web URLs to point to PHP script
Posted: Tue Mar 11, 2003 10:36 am
by brianharrell
Thank you for your time!
I want URLs like this
http://www.alltimefavorites.com/pro/dog ... blue/large
to redirect to
http://www.alltimefavorites.com/pro/
where the webserver will look for index.php by default and will parse the data from the original URL to read from a MYSQL db.
(I have the parsing script already to break the url data into an array)
I know that if I use
http://www.alltimefavorites.com/index.p ... blue/large
it works fine but the index.php looks stupid in this case.
How do I use mod_rewrite to do this without sending any error or redirect messages back to the search engines or browsers?
Thank you very much for your time.
Posted: Wed Mar 12, 2003 7:14 pm
by McGruff
Some links to a tutorial on this subject were posted here not so long ago but I'm damned if I can remember what they were.
Try a search on this forum and php builder. If I can dig the links out I'll post again.
Posted: Thu Mar 13, 2003 7:44 am
by enygma
actually, in PHP, it lets you drop the .php on the script, and you just add something like this to the httpd.conf:
<Files index>
ForceType application/x-httpd-php
</Files>
then, when they call this:
http://www.alltimefavorites.com/index/d ... blue/large
you can do:
Code: Select all
<?php
function processURI() {
$array = explode("/",$_SERVER['REQUEST_URI']);
$num = count($array);
$url_array = array();
for($i=1;$i<$num;$i++){
$url_array["arg".$i]=$array[$i];
}
return $url_array;
}
?>
and return the parts of the URL after the /index/ - in this case:
[0]=>dog
[1]=>collars
[2]=>blue
[3]=>large
or something....
Posted: Thu Mar 13, 2003 8:18 am
by brianharrell
Thank you for your help.
Where would I put my script?
alltimefavorites.com/index
and what would happen to my regular html files at
alltimefavorites.com/minnesota/index.html
I really appreciate your time!
Posted: Thu Mar 13, 2003 8:23 am
by enygma
Posted: Thu Mar 13, 2003 8:53 am
by brianharrell
Wow that works great!
Which is the bigger performance hit?
mod_rewrite or forcetype on the server with 100,000 page views per day?
ForceType example also found in this article:
http://www.devarticles.com/art/1/143/2
Thanks!
Another issue with URLS
Posted: Wed May 07, 2003 12:51 pm
by brianharrell
I need to have the following URLS rewrite to one PHP script.
I'm converting static pages to a dynamic php script.
http://www.mysite.com/blue/widgets-large-0993.htm
http://www.mysite.com/anysub/any-other- ... ts-093.htm
http://www.mysite.com/red/big-widgets-small-9923.htm
http://www.mysite.com/red/big/lovely/gr ... s-9923.htm
Where ANY url containing "widgets" would forward to
http://www.mysite.com/myscript.php
I've tried many options:
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
Rewriterule ^.*WIDGETS$ myscript.php?id=uri=%{REQUEST_URI} [L]
Does not work. File not found error