Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By catweazle on
I'm trying to add a login or register link to a page. The problem is that my site lives in a directory, for example:
My site is http://www.myhost.com/mysite, so the login url lives at http://www.myhost.com/mysite/user.
When I use
<a href="user">Login</a>
the link will point to http://www.myhost.com/mysite/node/login which is wrong !
And when I use
<a href="/user">Login</a>
the link will point to http://www.myhost.com/login which is equally wrong !!
Any pointers ?
Comments
hi
hi use this code in html
Thanks ! But...
Thanks ! But... I don't want to use "your site name" as I want the code to run on my test machine (127.0.0.1/mysite) and the production site without modifications...
Got it !
Got it ! I use
<a href="?q=user">Login</a> which generates the link http://myhost.com/mysite/node/27/user. When I click it, it points me to the login page. I don't understand why...
Is this a "correct" way to use Drupal ?
yes
there is no harm to use this type of code.... just use and run your site
To be honest, I think you're
To be honest, I think you're asking for problems 'down the road' by installing your drupal site in a normal subfolder. If I were you, I'd make it a proper subdomain, so the site can be accessed through mysite.domain.com rather than domain.com/mysite
A prominent example of this is portability:
You can move mysite.domain.com anywhere you wish.
You cannot move domain.com/mysite anywhere except another root/mysite folder.
Thanks ! How ?
Thanks ! But how do I do that ? Could you point me in the right direction ?
Are you using a WAMP package
Are you using a WAMP package on your local PC for development, or are you developing your site on your actual webhost?
If webhost, then making a subdomain should be a feature of the host's 'backend' that they've provided you with for managing your account (usually cpanel11 or Plesk, or a custom-built one like the webhost 1&1 provides).
If WAMP, then you'll need to follow the 'readme' for the WAMP you're using.
If you are using a WAMP, then you'll *definitely* need to use a subdomain for development (or develop in local root); if you didn't the site would break when you moved to your webhost server - all the internal paths would be wrong and you'd have to edit them manually by directly editing your database.