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

sumitshekhawat7331’s picture

hi use this code in html

<tr>
<td align="center" colspan="2"><a href="/your site name/?q=user/password">Forgot Password?</a></td>
</tr>
<tr><td></td></tr>
<tr>
<td align="center" colspan="2"><a href="/your site name/?q=user/register">New User Register Now!</a></td>
</tr>
catweazle’s picture

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...

catweazle’s picture

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 ?

sumitshekhawat7331’s picture

there is no harm to use this type of code.... just use and run your site

-Anti-’s picture

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.

catweazle’s picture

Thanks ! But how do I do that ? Could you point me in the right direction ?

-Anti-’s picture

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.