Question

I've been using a drupal 4.7 installation for many years, and have had a recent problem crop up. That is, the rewritten URLs are now displaying these characters: ?q= in every drupal generated URL as follows: http://sitename.com/?q=path/alias , where before it would be: http://sitename.com/path/alias .

My best guess as to why this might be happening, is that I recently began using some PHP code to add context-specific link styling within a few sideblocks. Here's the code:

<?php   $alias= $_GET['q']; ?>

<a <?php $pos=strpos($alias,"1234"); // node number
if(!$pos == false) {
echo 'style="color:black"'; 
} ?> href="internal/link/alias">Internal Link</a>

Or more recently:

<?php $path = isset($_GET['q']) ? $_GET['q'] : '<front>';
$alias = url($path, array('absolute' => TRUE)); ?> 

<a <?php $pos=strpos($alias,"internal/link/alias"); 
if(!$pos == false) {
echo 'style="color:black"';
} ?> href="internal/link/alias">Internal Link</a>

Could this be the problem? If so, any ideas about fixes?

Was it helpful?

Solution

I don't think your snippet is causing it. It only reads from the database; it does not make changes to URLs. Is mod_rewrite still enabled? This may be caused by a recent change to the server config. Check the output of phpinfo().

By the way, the option $absolute for url() is passed as a separate argument in Drupal 4.7, not in the $options array. Your call should be:

url($path, $absolute=TRUE);

OTHER TIPS

I'm thinking that your clean urls are just broken. When you don't have clean URLs turned on, all your URLs will look like http://example.com/?q=/foo/bar/baz. The rewrite rules translate requests from http://example.com/foo/bar/baz into http://example.com/?q=/foo/bar/baz to be processed internally.

You need to go back and make sure that your rewrite rules still work (can you even go to http://example.com/foo/bar/bazz ?) and that Drupal has clean URLs turned on.

Go into admin/settings and make sure Clean URLs is turned on.

Try the following:

  1. Upload an unmodified .htaccess file to the root of the site again

  2. Make sure your apache has mod_rewrite available. If you have shell access and it's an Ubuntu/Debian machine, just do

    a2enmod rewrite

  3. Check if the option is enabled on admin/settings

  4. Create a simple .php file on the root folder and type:

    phpinfo();

Then just see if the module is working.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top