Forum Moderators: coopster

Message Too Old, No Replies

Please rewrite a string for me

         

vic_msn

11:19 am on Apr 21, 2006 (gmt 0)

10+ Year Member



Can you rewrite
h*ttp://www.example.net/showcats.php?sbcat_id=49
to h*ttp://www.example.net/categoryname/
and similarly for subcategories.
if so post requesting the required files.
thank you.

[edited by: trillianjedi at 11:25 am (utc) on April 21, 2006]
[edit reason] Examplified..... [/edit]

hakre

11:25 am on Apr 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



looks like a topic for the apache forum. checkout the rewritemap directive in the docs:

[httpd.apache.org...]

if you're looking for php solution you might look for redirect instead of rewrite.

in both cases there should be many solutions already posted in this forum.

vic_msn

4:15 pm on Apr 21, 2006 (gmt 0)

10+ Year Member



i dont want to rewrite using .htaccess but rewrite using
the files the script uses.

inbound

4:27 pm on Apr 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A quick look at the 'header' documentation in PHP should help you understand this ( [uk2.php.net...] ). It's very easy to do a conditional redirect in PHP, you just need to make sure that nothing has been sent to the browser and send HTTP headers that send the browser/search engine merrily on their way to the correct address (remember to 301 for a permanent redirect). This is often a handy thing if .htaccess of config files are not available on shared hosting.

e.g.

<?php
// add conditional code if you wish,
// you would replace the string below
// with a variable that depends on the
// parameters passed to the script
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.example.com/");
exit;
?>

vic_msn

12:28 pm on Apr 22, 2006 (gmt 0)

10+ Year Member



i donot know php can you do this for me

inbound

12:54 am on Apr 23, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I didn't do it all for you as you would not learn that way, if you appear not to be putting effort into solving your problem when others try to point you in the right direction then you should be prepared to get little extra help. I'll cut you some slack and tell you what you need to look up (at www.php.net), it should take a few hours to gain a little understanding.

You will need to learn about the following:

How to create a simple PHP script.
PHP variables, probably strings is a good start.
The IF command.
Headers, as hinted in my previous post.

Good luck