Welcome to WebmasterWorld Guest from 54.157.81.13

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Extensionless URLs

     
9:37 pm on Feb 24, 2013 (gmt 0)

New User

joined:Jan 27, 2013
posts: 33
votes: 0


I found coding that will drop my .php extension on any page with a .php extension. Works fine.

So now, when I am hard coding the pages, do I use the extensionless urls?

Do I put the extensionless urls in my sitemaps?

I am just wondering about duplicate content penalties resulting from this.
9:40 pm on Feb 24, 2013 (gmt 0)

Senior Member from GB 

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

joined:Jan 27, 2003
posts:3332
votes: 140


The solution is simple enough - redirect from the .php extension to the extensionless URL.

The general practice is to determine the 'canonical' URL - the one that you will use in your internal links, sitemaps, and indeed, everywhere. Then force that format via permanent (301) redirects.

The redirects can be achieved with mod_rewrite. The output of the links is down to your PHP scripts.
2:53 am on Feb 25, 2013 (gmt 0)

Senior Member from US 

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

joined:Apr 9, 2011
posts:14162
votes: 541


So now, when I am hard coding the pages, do I use the extensionless urls?

If you mean: Do you save the physical file without an extension, NO. Everything has an extension. (Except, ahem, things with leading dot.) If you mean: Should internal links on your own pages give the extensionless form, YES.

Do I put the extensionless urls in my sitemaps?

Again YES. Your sitemap lists URLs, not physical location. Search engines should not even know the .php form exists.

The formula has been given in several thousand earlier threads in this forum. It goes

R
ewriteCond %{THE_REQUEST} real-name-here
RewriteRule real-name-here made-up-name-here [R=301,L]

RewriteRule made-up-name-here real-name-here [L]
3:03 am on Feb 25, 2013 (gmt 0)

New User

joined:Jan 27, 2013
posts: 33
votes: 0


Thanks. All of my physical pages of course have the .php extension. The script then redirects to the pagename (without .php)

I just think I now need to change all my hardcoded links to the extensionless version - which will require a little work, but I think it will be worth it.
3:20 am on Feb 25, 2013 (gmt 0)

New User

joined:Jan 27, 2013
posts: 33
votes: 0


Should I be using a trailing slash in my hard coded links?
5:02 am on Feb 25, 2013 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:May 31, 2006
posts:1283
votes: 23


How long have the pages been online, and why do you want to drop the extension? Also, how many pages are you talking about? 50? 500?

It's a better practice to never change URLs if possible. In other words if they're .php, leave 'em alone, and make new pages extension-less. That's more important on older, aged content that's getting traffic.

I would not use a trailing slash as that usually indicates a folder, although it really doesn't matter.
6:06 am on Feb 25, 2013 (gmt 0)

Senior Member from US 

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

joined:Apr 9, 2011
posts:14162
votes: 541


Should I be using a trailing slash in my hard coded links?

Only if your object is to pretend that each of your extensionless URLs is the index page of a directory that doesn't really exist. I don't think anyone hereabouts would advise you to do that.

If you use a trailing slash in one place you have to use it everywhere. Since we are not talking about real, physical directories, mod_dir will not step in and supply a missing slash.

Again: In all internal links and also in your sitemap, give the form of the URL that you want to appear in the browser's address bar.
8:54 am on Feb 25, 2013 (gmt 0)

Senior Member

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

joined:July 3, 2002
posts:18903
votes: 0


For pages, URLs should not end with a trailing slash.

URL with trailing slash denotes folder or index page of folder.
8:41 pm on Feb 25, 2013 (gmt 0)

New User

joined:Jan 27, 2013
posts: 33
votes: 0


Ok. Thank you.
3:27 am on Feb 27, 2013 (gmt 0)

New User

joined:Jan 27, 2013
posts: 33
votes: 0


The solution is simple enough - redirect from the .php extension to the extensionless URL. ---

So do I need to RewriteRule ^example\.php http://www.example.com/example [R=301,L] for all my pages?
5:09 am on Feb 27, 2013 (gmt 0)

Senior Member from US 

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

joined:Apr 9, 2011
posts:14162
votes: 541


You mean, listing all the pages by name and making a separate rule for each one?

That kinda blows the point of having Regular Expressions and captures.

I think you started by saying that you already have code that rewrites in the other direction, from the php-less URL to the .php location where the content lives. Your new redirect should be the exact mirror image of this code, and should come before it in htaccess.

That's assuming your rewriting code-- which you haven't said much about-- is also happening in mod_rewrite within htaccess. Can't imagine why it wouldn't, since that part is a single conditionless RewriteRule.
10:25 am on Feb 27, 2013 (gmt 0)

Senior Member

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

joined:July 3, 2002
posts:18903
votes: 0


msg:4549363
in thread [webmasterworld.com...] might be useful for what all the steps are.
11:26 am on Feb 27, 2013 (gmt 0)

Senior Member from US 

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

joined:Apr 9, 2011
posts:14162
votes: 541


And I now realize that the reason I was getting dizzy is that the same person really does have two threads going.

Whew.
11:35 am on Feb 27, 2013 (gmt 0)

Senior Member

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

joined:July 3, 2002
posts:18903
votes: 0


I hadn't noticed that, but had thought it had got rather busy with a lot of similar questions in the last 10 days.
6:46 pm on Feb 27, 2013 (gmt 0)

New User

joined:Jan 27, 2013
posts: 33
votes: 0


I apologize for starting two threads. I will just post on the other thread and I will try to ask clearer questions.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members