primary links: "node" is repeated twice in url

dam - June 6, 2008 - 10:52

Hi all

This is the issue:
In the primary link menu if I put http://host/dir/node/xy as path for an entry everything works ok.
If I put only node/xy (I prefer this notation in case of future modifications in path) the primary link array is rendered well but with this problem.
the first time i click on an entry, let's say Home, the browser goes on node/xy. When I am on node/xy If I click again on Home the outputted url is http://host/dir/node/node/xy
and, of course, it's wrong and I get a 404

It happens the same also using a clean url as path

Any idea?
Thanks in advance

Cheers
Dam

Whats your base directory?

Alan D. - June 6, 2008 - 11:35

Are you running out of a subfolder or straight from the domain? (eg: http://example.com/dir or http://example.com/)

If the former, make sure your settings.php base directory reflects the directory structure.

eg: (From memory) this should be $base_dir = '/dir/';

The line, $base_dir = '/';, should be there but commented out.

Also check the .htaccess file.

IF this is a menu only problem for the menu, make sure that your passing all your links through l(), or if you really need to manually set the menu path, use base_path() . '/dir/' . $path for all links;

Alan Davison
www.caignwebs.com.au

i was not precise

dam - June 6, 2008 - 12:28

thanks Alan for your kind reply

To reply to your questions:
- it's in a subfolder
- in settings.php I have: $base_url = 'http://www.squadrainformatica.com/smak'
This is the .htaccess

#
# Apache/PHP/site settings:
#

# Protect files and directories from prying eyes:
<Files ~ "(\.(conf|inc|module|pl|sh|sql|theme|engine|xtmpl)|Entries|Repositories|Root|scripts|updates)$">
  order deny,allow
  deny from all
</Files>

# Set some options
Options -Indexes
Options +FollowSymLinks

# Customized server error messages:
ErrorDocument 404 /index.php

# Set the default handler to index.php:
DirectoryIndex index.php

# Overload PHP variables:
<IfModule sapi_apache2.c>
   # If you are using Apache 2, you have to use <IfModule sapi_apache2.c>
   # instead of <IfModule mod_php4.c>.
   php_value register_globals        0
   php_value track_vars              1
   php_value short_open_tag          1
   php_value magic_quotes_gpc        0
   php_value magic_quotes_runtime    0
   php_value magic_quotes_sybase     0
   php_value arg_separator.output    "&amp;"
   php_value session.cache_expire    200000
   php_value session.gc_maxlifetime  200000
   php_value session.cookie_lifetime 2000000
   php_value session.auto_start      0
   php_value session.save_handler    user
   php_value session.cache_limiter   none
   php_value allow_call_time_pass_reference  On
</IfModule>

# Various rewrite rules
<IfModule mod_rewrite.c>
  RewriteEngine on
  Options All

  # Modify the RewriteBase if you are using Drupal in a subdirectory and the
  # rewrite rules are not working properly:
  RewriteBase /smak

  # Rewrite old-style URLS of the form 'node.php?id=x':
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{QUERY_STRING} ^id=([^&]+)$
  RewriteRule node.php index.php?q=node/view/%1 [L]

  # Rewrite old-style URLs of the form 'module.php?mod=x':
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{QUERY_STRING} ^mod=([^&]+)$
  RewriteRule module.php index.php?q=%1 [L]

  # Rewrite URLs of the form 'index.php?q=x':
  RewriteCond %{REQUEST_FILENAME} !-f
#  RewriteCond %{REQUEST_FILENAME} !-d
#  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>

Anyway I realize that I was not precise describing the issue. Now I have focused it better.

This is the web site http://www.squadrainformatica.com/smak/

When you load it, the menu is ok; after clicking on the menu entries you get http://www.squadrainformatica.com/smak/node/81. From this point all the url in the menu assume the form
http://www.squadrainformatica.com/smak/node/node/xy

It seems that drupal is not passing "index.php?q=" in the path, so apache rewrites starting from http://www.squadrainformatica.com/smak/node/ rather than http://www.squadrainformatica.com/smak/

That's why "node" is duplicated.

Now I'm lost because I don't know which mechanism drupal uses to produce links.
Probably it's just a stupid setting. Maybe also in apache settings...

Any idea?

try "RewriteBase /smak/"

Alan D. - June 6, 2008 - 12:37

I think both require trailing slashes. Try this in your apache config

Alan Davison
www.caignwebs.com.au

And your settings file

Alan D. - June 6, 2008 - 12:40

And in your settings file try:

<?php
$base_url
= '/smak/'
?>

And if your using clean urls, I don't think that this line is even needed!

Alan Davison
www.caignwebs.com.au

solved. it was my fault

dam - June 6, 2008 - 13:41

Thank you Alan again

I found the solution. It was my fault. I made a "sort of port" of garland theme to the smarty engine, but due to this problem http://drupal.org/node/265807 not yet solved (or better answered) I had to write this smarty code in page.tpl

            <!-- primary links   -->
            {if isset($primary_links) and $primary_links!=""}
            <ul class="links primary-links">
                        {foreach name=outer item=link from=$primary_links}
                            <li ><a href="{$link.href}">{$link.title}</a></li>
                        {/foreach}
                </ul>
                {/if}

but it's wrong. this works ( ?q= was left away):

            <!-- primary links   -->
            {if isset($primary_links) and $primary_links!=""}
            <ul class="links primary-links">
                        {foreach name=outer item=link from=$primary_links}
                            <li ><a href="?q={$link.href}">{$link.title}</a></li>
                        {/foreach}
                </ul>
                {/if}

thank you again

lol

dam - June 6, 2008 - 13:46

I realize now that I already fixed this before!!

http://drupal.org/node/265807#comment-867795 <-- the smarty code has "?q="

probably I deleted it accidentally ... or I'm really getting crazy :-D

anyway

dam - June 6, 2008 - 13:53

anyway I still need a better way to output primary links ...

(perhaps calling theme('links'...) from page.tpl ... but no idea in how to this through smarty engine)

if someone has some suggestions ... any help is appreciated

lol, use phptemplate

Alan D. - June 6, 2008 - 14:04

Alan Davison
www.caignwebs.com.au

you are right but

dam - June 6, 2008 - 14:12

but:
- I prefer smarty
- I need it because I have to merge other stuffs made using smarty
- at this point, it's a challenge ;-)

I have the same problem with

barretr - August 6, 2008 - 07:38

I have the same problem with clean urls enabled. I've tried setting <base href="{$base_pat}"> in my Smarty template, which outputs <base href="">. I've set $base_url = 'http://filebot/umuwi/drupal-6.3'; under settings.php, and RewriteBase /umuwi/drupal-6.3/ in .htaccess.

In the Smarty documentation $base_pat supposedly returns the base url of site

Am I missing something?

 
 

Drupal is a registered trademark of Dries Buytaert.