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.
using MOD_REWRITE to change web URLs to point to PHP script
Moderator: General Moderators
-
brianharrell
- Forum Newbie
- Posts: 5
- Joined: Tue Mar 11, 2003 10:36 am
- Location: MN USA
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:
and return the parts of the URL after the /index/ - in this case:
[0]=>dog
[1]=>collars
[2]=>blue
[3]=>large
or something....
<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;
}
?>[0]=>dog
[1]=>collars
[2]=>blue
[3]=>large
or something....
-
brianharrell
- Forum Newbie
- Posts: 5
- Joined: Tue Mar 11, 2003 10:36 am
- Location: MN USA
this would only effect things that were like
http://www.foo.com/index/test/1
and not
http://www.foo.com/minnesota/index.html
http://www.foo.com/index/test/1
and not
http://www.foo.com/minnesota/index.html
-
brianharrell
- Forum Newbie
- Posts: 5
- Joined: Tue Mar 11, 2003 10:36 am
- Location: MN USA
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!
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!
-
brianharrell
- Forum Newbie
- Posts: 5
- Joined: Tue Mar 11, 2003 10:36 am
- Location: MN USA
Another issue with URLS
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
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