Modify rewrite / clear urls

I have been using a drupal 4.7 installation for years and I am having a recent issue. That is, the rewritten URLs now display these characters :? Q = in every url generated by drupal like this: http://sitename.com/?q=path/alias where it will be preceded by: http://sitename.com/path/alias .

My best guess as to why this might be happening is that I recently started using some PHP code to add context sensitive link style in multiple side blocks. 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 a problem? If so, any ideas for fixes?

0


source to share


4 answers


I don't think your snippet is causing it. It is read only from the database; it doesn't make changes to urls. Is mod_rewrite supported? This could be caused by a recent server configuration change. Check the output phpinfo()

.

By the way, the option $absolute

for is url()

passed as a separate argument in Drupal 4.7, not in $options

. Your call should be:



url($path, $absolute=TRUE);

      

0


source


I think your clean urls are just broken. When you don't have clean urls all your urls will look like http://example.com/?q=/foo/bar/baz

. Rewriting rules rewrite requests from http://example.com/foo/bar/baz

to http://example.com/?q=/foo/bar/baz

for internal processing.



You need to go back and make sure your rewrite rules are still working (can you even go for it http://example.com/foo/bar/bazz

?) And that Drupal has clean URLs.

+1


source


Log into admin / settings and make sure clean urls are enabled.

+1


source


Try the following:

  • Upload the unmodified .htaccess file to the site root again

  • Make sure Apache has mod_rewrite. If you have shell access and it is an Ubuntu / Debian machine, just do

    a2enmod rewrite

  • Check if admin / settings option is enabled

  • Create a simple .php file in your root folder and type:

    phpinfo ();

Then just see if the module works.

0


source







All Articles