homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Mod Rewrite
Do I need to update all my links?

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

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.


becomes ...


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?



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

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.


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

Thanks for clarifying that.

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


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

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:// or add "testdomain.test" to your HOSTS file and browse to http:// testdomain.test/ instead.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved