Forum Moderators: phranque

Message Too Old, No Replies

.htaccess coding w/stealth & avoiding .html extentions

.htaccess stealth

         

awdevore

12:49 am on Oct 11, 2010 (gmt 0)

10+ Year Member


Two questions please:

#1 I wrote a simple .htaccess file. I realize I would like to stealth the destination URL so that the original URL still shows in the address bar. What code do I add to do that. For example, these are not my real domains but if my code is:

Redirect 301 /dog/index.html http://cat.com

I would like http://www.dog.com to still appear in the address bar even after the redirect happens to http://cat.com


#2 I wanted to also learn how to code an .htaccess file to redirect a URL written as http://dog.com/brush instead of written as http://dog.com/brush.html (see code below)? I don't want users to have to type in the /brush.html, but rather just the /brush

It doesn't seem to work with this line of code below, although I thought it would (Note that I would have the domain dog.com in my cpanel pointing to the /dog directory):

redirect 301 /dog/brush/ http://cat.com

g1smd

1:16 am on Oct 11, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



A redirect forces the browser to make a new request for a new URL in a new HTTP transaction, so the user will always see the new URL in the address bar.

For your .html/extensionless problem you need a rewrite not a redirect. Link to the extensionless URL from the pages of your site, and then set up a RewriteRule that connects the extensionless URL request (that arrives at the server once that link is clicked) to the internal server filepath and filename with extension.

This is a regular question here and there are many thousands of prior threads with example code to get you started. Make sure that you fully understand the differences between an external redirect and an internal rewrite, and that URLs (with domain names) are used "out on the web" and filepaths (without domain names) are used "inside the server".

awdevore

11:34 am on Oct 11, 2010 (gmt 0)

10+ Year Member



I thank you for you response. I know there is a way to do this. Although the new URL is actually being fetched and delivered, the old URL is maintained in the address bar purely for appearances. Let me know if you find out anything on how to it?

jdMorgan

4:25 pm on Oct 15, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



*You* can find out how to do it by looking in our Apache Forum Library... :)

[webmasterworld.com...]

Jim