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?
-
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
$absoluteforurl()is passed as a separate argument in Drupal 4.7, not in the$optionsarray. Your call should be:url($path, $absolute=TRUE);Michael D : 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. -
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 fromhttp://example.com/foo/bar/bazintohttp://example.com/?q=/foo/bar/bazto 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.Michael D : 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= -
Go into admin/settings and make sure Clean URLs is turned on.
-
Try the following:
Upload an unmodified .htaccess file to the root of the site again
Make sure your apache has mod_rewrite available. If you have shell access and it's an Ubuntu/Debian machine, just do
a2enmod rewrite
Check if the option is enabled on admin/settings
Create a simple .php file on the root folder and type:
phpinfo();
Then just see if the module is working.
0 comments:
Post a Comment