In #222515 morphir attempted to add a url alias with a request parameter.

Example:
commitlog?repos=1

When the handler is being determined the entire string is used instead of the path portion.

The desired path being:
commitlog

I wrote a simple patch that corrects this by checking for variables in the path. It then corrects the path and parses the variables. The variables are then added to the appropriate arrays so that modules can process them like normal.

CommentFileSizeAuthor
#1 url_alias_with_query.patch952 bytesboombatower

Comments

boombatower’s picture

StatusFileSize
new952 bytes

I suppose I should attach the patch.

I assume this could be adapted for 6.x and HEAD.

chx’s picture

Status: Needs review » Needs work

Something is not right, get q does not contain the query string.

chx’s picture

Status: Needs work » Closed (won't fix)
cwgordon7’s picture

Version: 5.x-dev » 7.x-dev
Status: Closed (won't fix) » Active
dugh’s picture

subscribe, I had a patch to do this in drupal 5, but forgot it. I need a patch for drupal 6 now.

brian_c’s picture

I have this working in D7 via hook_url_inbound_alter(): http://drupal.org/node/118072#comment-4706374

killah89’s picture

Got to work for D6 please.

Thanks :D

geek-merlin’s picture

Title: Url Alias with Query String » Url Alias with Query String (D7)
Issue summary: View changes
Related issues: +#118072: Allow query strings in URL aliases

This totally makes sense. Patch looks like a good starting point.
D8 will take a totally different approach so tagging this D7.

amit0212’s picture

I think you can do this with the Redirect module (it won't provide an alias in its truest form but it will forward you on to the right page).

In .htaccess you could a custom RewriteRule before Drupal's main index.php rule:

RewriteRule ^myownstuff$ stuff?owner=myself [L,QSA,R=301] # QSA and R=301 are optional here

If neither of these work there is a quick and dirty way in a custom module:

function MYMODULE_init() {
if ($_GET['q'] == 'myownstuff') {
drupal_goto('stuff', array('query' => array('owner' => 'myself')));
}
}
If you've got more than one path to forward/a pattern etc. you'll have to extend this a bit but the logic will work.

I think the .htaccess is probably the best way as it doesn't actually forward on to the URL but masks it internally which I guess is what you're after.

You might also want to look at hook_url_inbound_alter() which I believe you can use to get this kind of functionality...I've not used it before so I can't comment further though.

Status: Active » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.