Is there some way to control the pattern Drupal uses to generate its URLs in links?

I'm trying to get rid of extraneous information in the URL such as the Drupal's folder name.

For example, my URL should read:

  http://mysite.com/my-page.html

But Drupal makes it

  http://mysite.com/drupal/my-page.html

Is there an easy way to tell Drupal how to constructu URLs? If not, what is the best hard way (write a module to implement hook_build_link?)

Thanks,

Chadj

Comments

awrowe’s picture

Have a look for the version of the pathauto module, you can really take control of the urls with that.

cheers,

There's a flip side?

tostinni’s picture

Hi,
This is not Drupal who put the URL with drupal/ it's apache.
What happened is that your website is installed in the Drupal directory inside your Apache DocumentRoot directory which is your website root.

So just move drupal outside its directory directly at the root or update DocumentRoot in httpd.conf to point to your drupal directory.

chadj’s picture

Is there any way to take control of how URLs are written? Right now Drupal generates 'dumb' URLS that use its physical location plus the menu system or an alias.

I'd like to take control of generating the base url (http://mysite.com/ part) so I can clean things up and use my own URL patterns. My URL patterns can be easily translated back into something Drupal can understand in the HTACCESS file.

Is there an easy way to hook into all generated links? PathAuto just doesn't seem to address the full URL. ;)

- Chadj

tostinni’s picture

Hum, sorry but I don't understand well the pb you have.
Do you refer by "dumb URLs" to the current "node/id" that drupal is using ?
What you mean by "take control of generating the base url" ?
What are your "own URL patterns" ?

If you enable path module, in each node creation you can create a custom path, if you enable pathauto, this will be done automatically regarding pathauto settings.

armanschwarz’s picture

I wrote a tutorial on how to automatically generate URL aliases like mysite.com/username/my-article, here is the tutorial:

http://www.bottleweb.org/administrator/unique-urls-drupal-site-members

If you found it useful please share it around. Sharing is caring!