Welcome to WebmasterWorld Guest from 54.163.35.238

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Mod Rewrite

Do I need to update all my links?

     

Tiebreaker

9:30 am on Feb 20, 2011 (gmt 0)

10+ Year Member



Sorry if this is an obvious question - but I've been searching online for ages, without getting an answer to it.

I've got a simple bit of mod rewrite code in my htaccess file, which removes the file extension from the URL.


domain.com/filename.html

becomes ...

domain.com/filename


This all works great if you directly type in the file name without the extension - the page displays with the extensionless file name in the address bar

BUT - if you follow a link to the page on my website, the extension is still displayed - obviously, this is because the file name extension is present in the HTML source code of the link.

Clearly, one solution to this is to remove all the extensions from my links - easy enough to do, but that means that all the links are broken when I am viewing the site locally in Dreamweaver preview mode.

So my question is - do I HAVE to remove the extension from all my links, or is there a mod rewrite code that will display an extensionless URL even if the extension is left in the links?

g1smd

10:55 am on Feb 20, 2011 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Links "define" URLs, so the links must point to the URLs that you want users to "see" and "use".

The act of clicking the link sends a URL request to the server. It is too late to "change" that URL after the click.

One other thing. In order to remove Duplicate Content issues from your site, you should set up a 301 redirect such that if
<anything>.html
is requested, the user is redirected to
www.example.com/<anything>
.

All of the redirect and rewrite code should use RewriteRule directives and the external redirects must be listed before the internal rewrites.

Finally, set up a local copy of Apache on a PC or laptop in order to view your site offline.

Tiebreaker

8:44 am on Feb 21, 2011 (gmt 0)

10+ Year Member



Thanks for clarifying that.

So, if I have Apache on my PC, I won't have broken links when viewing my site offline?

g1smd

12:13 pm on Feb 21, 2011 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Yes, as long as the host name is not mentioned in the links, as that would send the request to the real site.

Install Apache and browse the local copy of your site at http:// localhost/ or http:// 127.0.0.1/ or add "testdomain.test 127.0.0.1" to your HOSTS file and browse to http:// testdomain.test/ instead.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month