tags:

views:

468

answers:

4

Hi there,

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?

A: 

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);
Ayman Hourieh
Thank you Ayman! Helpful info. Will check as best I can. Unfortunately, my server access is quite limited, so my workarounds must be innovative... long story.
Michael D
+1  A: 

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.

Sean McSomething
Yes, the rewrite rules still seem to be working, as http://example.com/foo/bar/bazz still works. It's only the drupal generated URLs that add the extra characters ?q=
Michael D
+1  A: 

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

Steve P
A: 

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.

IvanSF