views:

30

answers:

5

How do you do this...

When the user enters

http://domain.com/mycompanyname

browser redirects to

http://manager.domain.com/page.php?company=mycompanyname

Note: mycompanyname value is dynamic

+1  A: 
Redirect http://domain.com/mycompanyname http://manager.domain.com/page.php?company=mycompanyname
Alexander.Plutov
What happens if the value "mycompanyname" changes?
K001
It is just an example.
Alexander.Plutov
A: 

Try this solution (copied from my answer to similar question ) Other than using mod_rewrite, as already reported you can do a little of magic with a simple trick.

Put into the .htaccess a directive like this one

<FilesMatch "^servlet$"> 
  ForceType application/x-httpd-php
</FilesMatch> 

substitute ^servlet$ with a regular expression of your choice (it will be the name of your dispatcher)

The file servlet should be similar to this

<?php
  $data = explode('/',$HTTP_SERVER_VARS['PATH_INFO']); // $data[0] always empty
  $fileToInclude = $data[1].'.php';
  if (file_exists($data[1]) {
     $params=array_slice($data,2); // you can do here something more sophisticated
                                   // for example sanitize parameters or assemble 
                                   // an hash
     include ($fileToInclude);     //Think to this file as a servlet
  } else {
    // issue a 404 error, maybe one of the 500 series
  }
?>

The url can have the form: http://yoursite/servlet/reports/sales/2009 you can also reach the form http://yoursite/reports/sales/2009 plaiyng a little with the .htacces and the dispatcher.

This method has the advantage that mod_rewrite is not required as FilesMatch (1.3+) and ForceType (2.0+) are in the apache core

See for reference
http://httpd.apache.org/docs/2.2/mod/core.html#forcetype
http://httpd.apache.org/docs/2.2/mod/core.html#filesmatch
http://www.devarticles.com/c/a/Apache/Using-ForceType-For-Nicer-Page-URLs/1/

Eineki
A: 

place the following code in your http://domain.com/mycompanyname

<?php
    header('Location: http://manager.domain.com/page.php?company=mycompanyname');
?>
Ninja Dude
A: 

You can use this at the top of your php page As soon as user visits your page, user would be redirected to a new-url

Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.facebook.com/people/Wasim-Karani/1158880522" );

In this case user will be redirected to http://www.facebook.com/people/Wasim-Karani/1158880522

Wazzy
Also can write header above html tag
Wazzy
A: 

I believe PHP will do the job, so I will tell you about it. First get the URL of the page then split it to get mycompany and save it in a variable. Now let the PHP loads the new page with the variable ...

<?php

$URL = ($_SERVER['HTTPS'])=='on'?'https':'http'.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

$companyName = explode('/',$URL);

$URL = 'http://localhost/anything/'.$comapnyName[3];

header('Location: http://localhost/anything/'.$companyName[3]);

exit();

?>

this will do it using the PHP ...

sikas