URL is an abbreviation of "Uniform Resource Locator" and is the page's address on the web. It is the "name" by which a browser identifies a page to display. In the example "Check us out at mysite.com." the part mysite.com is the URL for the home page of your web site. Users use URLs implicitly to locate content on the web.

Drupal uses "nodes" to identify pages by their position in your database. So your page on "The History of the Macadamia Nut - Part 1" might be known as "node/167." to Drupal. By maintaining the list of nodes in your site, the URLs are maintained as a result, which in turn enables your visitors to find your site's content.

Drupal has a feature called "URL Alias" that allows you to provide a more understandable name to the content. As far as browsers, servers, and search engines go, it is totally unnecessary. But for humans, it is nearly mandatory. This is why most consultants tell people to always turn on the Path core module, which supports URL aliasing.

So, just before you submit that treatise on macadamia history, and if you have the Path module enabled (and you will want it), then you'll see a section on the edit page that says "URL path settings." So let's say you want your visitors to see it as http://www.example.com/MacadamiaHistory. In the URL field, enter MacadamiaHistory.

You can administer the URL Aliases directly on the node edit or add forms, or by doing the following:

First, visit the page you created. In your browser's address field, you'll see its URL. On the end it will probably say "node/xxx" where xxx is some number. Write down that number.

Now go to:

Configuration > Search and Metadata > URL Aliases (Drupal 7)

Administer > Site building > URL Aliases (Drupal 6)

There's an "Add Alias" tab at the top. In the top box, enter "node/xxx" from above. In the second box, enter "MacadamiaHistory".

Automatic Alias Generation

If your site is going to have lots of content, particularly user-submitted content, you might want to look at the PathAuto module. Not only will this module automatically generate URL aliases for new content (according to rules you can set up), but can even go back and change aliases in bulk.

Path and clean URLs

Note that the Path module does not require Clean URLs. As an example:

With clean URLs:

Without clean URLs:

Permissions

After you enable the Path module, you need to give the appropriate roles permission to use it in admin/user/permissions. Scroll down to the Path module to enable "administer url aliases" and/or "create url aliases" permissions.

Comments

rayjames’s picture

If you are adding aliases in through code, make sure you don't add a slash / at the end of the src or the dst. This will make it not work and you will be scratching your head. Putting a .htm works though.

Example:

Good dst = news/category/business
Bad dst = news/category/business/ (Will not work!)

Thanks.

Live24x7’s picture

Google will see the same content at two different URL this way.
Does URL alias lead to duplicate content issue with google ?

If yes, is there a way to use alias and still overcome the duplicate content issue ?

NancyDru’s picture

Google will only see the alias version; there is no duplicate content. Internal links, however, may be a different story.

kartsims’s picture

what makes you think there is no duplicate content ?
i can access the same page using http://mysite.com/node/XXX and http://mysite.com/the-url-alias

no redirection code (301, 302,...) is sent. if ever google finds the 2 distinct urls with the same content, he will consider it as duplicate content, right ?

NancyDru’s picture

Why is Google indexing both addresses? You can also use the Global Redirect module.

vasrush’s picture

You can use "Disallow: /node/"
in your robots.txt file

NancyDru’s picture

mandelic’s picture

Hi,

Is it possible to generate two different url patterns for all taxonomy terms?

I have this automatic url generating now

category/[taxonomy_term]

but I also need this pattern

category/[taxonomy_term]/example or category/[taxonomy_term].html

Thanks,
Milorad

NancyDru’s picture

You don't want that to happen. If the search engines see duplicate content, your ranking goes down the drain. And the ".html" is out of date.

thepocketgeek’s picture

Is there a way to set the URL Alias conditionally based on a field in the node? For example if a field is set to A the URL should read

A/category/some-web-page-name

and if it is set to B:

B/category/some-web-page-name

nielsvoo’s picture

Is there a way to use tokens in a URL alias?

NancyDru’s picture

Pathauto does exactly that.

ryan.malenfant’s picture

Hi Drupal community,

This is my first post. Mostly because I can usually find exactly what I'm looking for :-)
Anyways I have just created a site and have named URL Aliases for all of my pages. However when I create a link to another page through an internal path the URL turns up with the "node/#" form instead of the alias for which I have previously assigned to it.

Any suggestions?

Thanks,

R

NancyDru’s picture

satrece’s picture

Hi,

I have used the url alias module in drupal 7. I tried to change the url for the below

http://www.xxx.com/party-calendar to http://www.xxx.com/nightlife/party-calendar.

After i have changed url using url alias. Still im able to access both urls (http://www.xxx.com/party-calendar) pointing same page. Chance Google will crawl both urls im right. I don't need this url to crawl http://www.xxx.com/party-calendar. But it should redirect to new url as per my understanding. Is my understanding correct?.

Thanks,
Satheesh