Google Answers Logo
View Question
 
Q: redirect html code that is user friendly to a .php page ( Answered 5 out of 5 stars,   5 Comments )
Question  
Subject: redirect html code that is user friendly to a .php page
Category: Computers
Asked by: newbusinessowner-ga
List Price: $15.00
Posted: 07 Apr 2005 12:55 PDT
Expires: 07 May 2005 12:55 PDT
Question ID: 506404
I need to know how to redirect someone who enters the following:

if someone types in www.mywebsite.com/custom in the address bar that 
it automatically will bring them to the 
www.mywebsite.com/CUSTOMPLANS/customhome.php

how do I get this redirect to acknowledge the initial url in my
brochure and re-direct to the ....php address.

This is not my real web address by the way.

Request for Question Clarification by leapinglizard-ga on 07 Apr 2005 13:33 PDT
Does your webhost run Apache? If so, I can give you an httpd.conf file
that will rewrite the URL as you specify. This is better than
redirection.

leapinglizard

Clarification of Question by newbusinessowner-ga on 07 Apr 2005 14:25 PDT
Yes, apache web server
Answer  
Subject: Re: redirect html code that is user friendly to a .php page
Answered By: leapinglizard-ga on 08 Apr 2005 18:37 PDT
Rated:5 out of 5 stars
 
Dear newbusinessowner,

The commenters below suggest several variants of the Redirect
directive. For my part, I recommend the more powerful Rewrite directive.

The first step to take once you're logged in as administrator is 
to navigate to the website's root directory, where the home page is
located. Now open the file .htaccess if it exists, or make a new one if
it doesn't, and add to it the following lines.

    RewriteEngine on
    RewriteBase /
    RewriteRule custom CUSTOMPLANS/customhome.php

Once you've saved the .htaccess file, any user's request for the
www.mywebsite.com/custom page will be rewritten as a request for
www.mywebsite.com/CUSTOMPLANS/customhome.php . The user won't know
where the customhome.php file is located or even that they're viewing 
a .php file, since their browser will continue to show the location as
www.mywebsite.com/custom . This is a great convenience because you can
always change the implementation or location of the custom page without
asking users to change their bookmarks. You need merely adjust your
.htaccess file accordingly.

If you do want to perform an external redirect, which means that
the user's browser is told to automatically make a request for
CUSTOMPLANS/customhome.php instead of custom, just add the [R] flag to
the last line, so that it reads as follows.

    RewriteRule custom CUSTOMPLANS/customhome.php [R]

In this case, the user's browser will actually change from
www.mywebsite.com/custom to www.mywebsite.com/CUSTOMPLANS/customhome.php .

Regards,

leapinglizard

Request for Answer Clarification by newbusinessowner-ga on 08 Apr 2005 18:49 PDT
I apologize, but I don't know how to create a .htaccess file.  How do you do that?

Clarification of Answer by leapinglizard-ga on 08 Apr 2005 18:57 PDT
You can use any text editor to make a .htaccess file. If you have
terminal access to the webhost, the pico editor is probably at your
disposal. Just type

    pico .htaccess

to get started and use the commands displayed at the bottom of the
screen. Once you're done entering the text, type Ctrl-X to exit and
press Enter when it asks whether you want to save changes, then Enter
again to confirm the file name.

Another possibility is to use the cat command to enter everything in
one shot. Execute

    cat > .htaccess

and then type or paste in the three lines above, press Enter, and
finally type Ctrl-D to end the file. Voila, you have a new .htaccess
file.

Finally, if you don't have terminal access, make the .htaccess file on
your local machine using a simple text editor such as Notepad, and
upload it to your webhost with whatever tools you normally use for
file transfer.

leapinglizard

Request for Answer Clarification by newbusinessowner-ga on 09 Apr 2005 05:29 PDT
no clarification, just a simple thanks.
we discovered how to update the htaccess we had to call our hosting
company, we had to dust off some of our website to get it done.  never
touched that file, so thanks.

this is the best tool!
I appreciate your help.

Clarification of Answer by leapinglizard-ga on 09 Apr 2005 06:33 PDT
Thank you for the kind words and the handsome tip.

leapinglizard

Request for Answer Clarification by newbusinessowner-ga on 18 Apr 2005 04:43 PDT
Not sure if this works after you submit a rating and pay, but here goes.  

This worked and was quite helpful, but I had some problems with images
that were traced back to the .htacess file.

I had some image problems after this was done that was not noticed right away.  

The redirect lines caused a 500 error on the server.  Many suggestions
were made to fix this problem, and I'm sure it would have about
putting images in different folders, but I decided on a simpler
redirect routine that was found on the following page:
http://www.sa.sdsu.edu/communications/styleguide/redirect-instructions.html

just in case others see this thread.  I do believe this helped alot
though and I stick to my rating.  Good job, Google experts!
newbusinessowner-ga rated this answer:5 out of 5 stars and gave an additional tip of: $25.00
You gave me the best answer. I have another problem, that I think I'll
share soon.  I hope you get it.  It is more complex.
I can't wait to use this site again!

Comments  
Subject: Re: redirect html code that is user friendly to a .php page
From: roughtoughhough-ga on 07 Apr 2005 15:25 PDT
 
In the httpd.conf file add to the <virtualhost> block a Redirect directive:


<virtualhost >
...
Redirect permanent /custom /CUSTOMPLANS/customhome.php
...
</virtualhost>



You can find more documentation on Redirect and other similar
directives at http://httpd.apache.org/docs/mod/mod_alias.html.

And a site with another example is here: http://www.freebsddiary.org/redirect.php.
Subject: Re: redirect html code that is user friendly to a .php page
From: compuguru-ga on 07 Apr 2005 18:07 PDT
 
If you don't have access to httpd.conf, you can use .htaccess files. 
In your root web directory, add this to your .htaccess file (create it
if it doesn't exist):

RedirectMatch .*\custom http://www.mywebsite.com/CUSTOMPLANS/customhome.php
Subject: Re: redirect html code that is user friendly to a .php page
From: compuguru-ga on 07 Apr 2005 20:00 PDT
 
By the way, since Google doesn't accept new researchers, if I answered
your question to your satisfaction (meaning you can cancel your
question), tips are very appreciated:
https://www.paypal.com/xclick/business=paypal%40brianburton%2eorg&currency_code=USD
Subject: Re: redirect html code that is user friendly to a .php page
From: rolosworld-ga on 08 Apr 2005 07:35 PDT
 
you could create the  custom directory and inside of it create an index.php with
<?php
header( "Location:http://www.mywebsite.com/CUSTOMPLANS/customhome.php" );
?>

or add the following line to the  http://www.mywebsite.com/.htaccess   :
Redirect permanent /custom http://www.mywebsite.com/CUSTOMPLANS/customhome.php

if you dont have the  .htaccess .. create it.
Subject: Re: redirect html code that is user friendly to a .php page
From: hansons-ga on 13 Apr 2005 07:13 PDT
 
Sorry I can't help you. But you can contact http://www.silverlion.biz
in this regard.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy