SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict Zapppa's Avatar
    Join Date
    Aug 2009
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Url Format: How do I have page links without extension at the end?

    Hi

    I have a site with around 30 pages. I would like users to be able to type in

    www.mysite.com/example

    At the moment to get to this page my users would have to type www.mysite.com/example.php

    How would I make this feature ?

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,598
    Mentioned
    411 Post(s)
    Tagged
    6 Thread(s)
    The easiest thing to do is to let them type mysite.com/example/—that is, with a slash on the end. You do this by creating a folder inside your root folder called /example/ and moving the example.php file to that folder and renaming it as index.php.

    An alternative is to rewrite your URLs with a .htaccess rule, but that's a little tricker and messier ... although it means you don't have to restructure your site.

    Often sites have a structure like mysite.com/example because their pages are served up by a CMS that creates such URLs by default. But rebuilding your site within a CMS is most likely the most time consuming option.

  3. #3
    Mouse catcher silver trophy
    Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,828
    Mentioned
    110 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by ralph.m View Post
    The easiest thing to do is to let them type mysite.com/example/—that is, with a slash on the end. You do this by creating a folder inside your root folder called /example/ and moving the example.php file to that folder and renaming it as index.php.

    An alternative is to rewrite your URLs with a .htaccess rule, but that's a little tricker and messier ... although it means you don't have to restructure your site.
    Or just turn on 'multiviews' in .htaccess, which means that (as long as there is no other file or folder with the same name) you can leave off the file extensions and it will figure out what page you want and take you to it automatically.

  4. #4
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,623
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stevie D View Post
    Or just turn on 'multiviews' in .htaccess, which means that (as long as there is no other file or folder with the same name) you can leave off the file extensions and it will figure out what page you want and take you to it automatically.
    That's cool. But wouldn't that create Canonicalization. Aka redundant content. Like www and no www - like site.com/index.php and just site.com

  5. #5
    Mouse catcher silver trophy
    Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,828
    Mentioned
    110 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by EricWatson View Post
    That's cool. But wouldn't that create Canonicalization. Aka redundant content. Like www and no www - like site.com/index.php and just site.com
    If you only ever reference the non-extension format of the URL then that's all that should ever appear. Failing that, you can simply add a canonical link into the <head> giving the preferred URL format.

    The problem with using a visible rewrite is that search engines will genuinely use the actual URL rather than the alias URL (in this case, they would normally prefer the URL with extension), whereas if you're trying to promote your site then you are likely to want to prefer the non-extension format.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •