Forum Moderators: coopster

Message Too Old, No Replies

how to use this script

         

fastcreators

10:13 am on Aug 15, 2005 (gmt 0)



hi guys i found a php script that helps to create SEO friendly URLs but i am not getting how to use it so please have a look at this and i wonder if you could give an example of using this

here is the code,,if(isset($PATH_INFO)) {

$vardata = explode('/', $PATH_INFO);

$num_param = count($vardata);

if($num_param % 2 == 0) {

$vardata[] = '';
$num_param++;
}

for($i = 1; $i < $num_param; $i += 2) {

$key = $vardata[$i];
$vardata[$i] = $vardata[$i+1];

$HTTP_GET_VARS[$key] = str_replace
('¦', '/', $vardata[$i]);
}
}
?>

thanks

ryan26

10:52 am on Aug 15, 2005 (gmt 0)

10+ Year Member



Bah. Looks complicated. Go with mod_rewrite. It's simple.

[httpd.apache.org ]

fastcreators

6:30 pm on Aug 15, 2005 (gmt 0)



well i am already working over mod rewrite but i think php is a powerful language and there must be some way to rewrite URLs on fly with pure php, so any genius programmer here please share your knowledge with us

jatar_k

7:04 pm on Aug 15, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



what is it you are trying to do with that fastcreators?

I guess it could be used as a function to create in page friendly urls but it would have to be built in concert with your specific rewrite rules.

If the two don't match exactly then it won't go where it is supposed to.

fastcreators

10:35 am on Aug 16, 2005 (gmt 0)



i have a site that generates Dynamic URLs like
www.domain.com/index.php?var1=value1&var2=value2

i want to change these URLs with this function to SEO friendly URLs on fly e.g

www.domain.com/index.php/value1/value2 OR

www.domain.com/value1/value2

so please help me if you can give me an example that how can i use it, thanks for your time

dreamcatcher

11:10 am on Aug 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sounds like mod_rewrite is what you want as previously mentioned.

Try the mod_rewrite generator:

[webmaster-toolkit.com...]

dc

fastcreators

6:45 pm on Aug 16, 2005 (gmt 0)



hi thats awesome tool BUT its not working for me
i tried to generate a pattern for
[localhost...]

it gives me

Options +FollowSymLinks
RewriteEngine on
RewriteRule index/(.*)/(.*)/(.*)/(.*)/$ /nnmoj/index.php?$1=$2&$3=$4

for URLs like (http://localhost/index/linkname/xbox/maincat/games/)
first of all i dont want URL like the above i want somethig like (http://localhost/index/xbox/games/)
and secondly its not working when i write the URL (http://localhost/index/linkname/xbox/maincat/games/) it gives error like page not found.....any idea?

dreamcatcher

8:10 pm on Aug 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Did you add a page name? You need to add a page name for a directory structure.

I tried it with:
[domain.com...]

Which will output a mod re-write of:
[domain.com...]

The mod_rewrite rule is:

Options +FollowSymLinks
RewriteEngine on
RewriteRule index/(.*)/(.*)/(.*)/(.*)/$ /index.php?$1=$2&$3=$4

dc

fastcreators

4:15 am on Aug 17, 2005 (gmt 0)



hi
i used this in my .htaccess

Options +FollowSymLinks
RewriteEngine on
RewriteRule moj-(.*)-(.*)\.htm$ /nnmoj/index.php?linkname=$1&maincat=$2

i go it by using Rewrite pattern generator tool on this site it has some thing in the end of $2 i removed that and now its working very fine with URLs like [localhost...]

where MOJ is the page name that i added
i have been working over this mod rewrite for the last one and half month and tried all forums, to see it working is a dream comes true feeling :) thank u very much fellows this forum and its memebers are just awesome thanks again for so much help