Home > path aliases > URL, wildcards, path

URL, wildcards, path

March 24Hits:0

I am having problems with a sort of pattern matching or path parsing issue.

If I have the following URL: http://www.mysite.com/sem-one-two/play

I have an application that runs at /play, which is not within Drupal.

What I want to do is take URLs, like the above, and pass them to the app.

So in this case, an SEM add links here: http://www.mysite.com/sem-one-two/play

Basically, I want to make the 'sem-one-two' mean nothing in Drupal, but pass it along to the app. In the module Match Redirect (https://drupal.org/project/match_redirect), Im able to take any URL, like above, and redirect to '/play'. Which gets me half-way, but I need Drupal to ignore 'sem-one-two' if it ends in '/play', but still pass it along to the app.

Am I making any sense? Is there anyone out there that understands what Im asking and has any ideas?

thanks, Mac


You could do it in your .htaccess file with 301 redirects. Have a look here: http://www.lionseo.com/blog/htaccess-redirect-301/

A couple of ways to look at this in a custom module:

With hook_init() you should be able to do something like this:

function YOURMODULE_init() {

  if (arg(1)=='play') {  //  arg(0) is equal to sem-one-two, arg(1) is equal to play, in your example anyway


but this doesn't take into account any caching of pages for anonymous users so I really don't know how it might work in the real world but if you don't care about the first argument, it should be ok. (hook_boot() is run for anonymous users/cached pages but does leave out edge caches such as Varnish etc)

What you most probably IMHO should do is something with hook_menu(), eg set up something like this:

function YOURMODULE_menu() {

  array $items;

  $items['your-module/%/play'] = array(
    'title' => 'Play',
    'page callback' => 'yourmodule_play',
    'page arguments' => array(1),
    'access callback' => TRUE,

  return $items;


along with:

function yourmodule_play($what) {

  // do whatever with $what...


This way, you have one menu callback for everything your module wants to "play" plus you know what the "two words" are you are dealing with.

Note that in this second example, it is prefaced with your-module as I really haven't seen (and personally think it to be in poor form to have) the first argument in a Drupal path to be itself a wildcard.

Related Articles

  • URL, wildcards, pathMarch 24

    I am having problems with a sort of pattern matching or path parsing issue. If I have the following URL: http://www.mysite.com/sem-one-two/play I have an application that runs at /play, which is not within Drupal. What I want to do is take URLs, like

  • GET an url or path, provided as string, in an rspec testJuly 12

    For a controller that determines the behaviour of a sidebar, I need to call several urls; the sidebar will change (a.o) based on the page on which it appears. describe SidebarController do before(:each) do @sidebar = SidebarController.new end it 'sho

  • Is there any way to get the windows cmd shell to expand wildcard paths?August 12

    Occasionally, the cmd shell's inability to expand wildcard paths can really be an inconvenience. I had to pass 100 files in a directory to a program, and couldn't type *.ext. Instead, I used mingw's 'ls' to dump the list to a file, then replaced newl

  • Which mysql drupal 7 tables contain the URL Alias path data?

    Which mysql drupal 7 tables contain the URL Alias path data?June 15

    Im looking to manually change a node's URL path as my edit button throws me an error upon clicking it since this was due to orphaned data left over from some other uninstalled modules. Which tables contain the URL alias path data in drupal 7? -------

  • Get node url alias/path when loading the node using node_load()October 22

    Does the node_load() does not return the node url alias in the node object or am I missing something. I know one way of getting the url alias/path is using the drupal_get_path_alias("node/NODE_ID"), however I was hoping the object return by node

  • Where are the permissions need for a content creator to set the URL and path alias for an article?February 21

    I am creating content as a user given the necessary permissions but I can't find the settings needed to set the URL and path alias for an article I am creating. I have checked all the permissions and there doesn't seem to be anything preventing? Does

  • Apache: How to always return 404s for URLs whose path component starts with "//"November 26

    How do I configure apache to always return a 404 for URLs whose path component starts with two slashes (i.e. "//")? We're getting such requests only from bots that don't understand scheme-relative URLs (so when they see a URL like "//somecd

  • Nginx convert URL to path on serverOctober 19

    I have a problem with converting URL into path to file. For example. I want open file /var/www/html/dir1/dir2/dir3/file_one.conf in browser by link http://domain.com/dir1.dir2.dir3.file_one Directories count can be a different. In one case 2 director

  • French language not showing url alias pathJanuary 10

    I have installed multilingual module and added french country for this. Added one content with English & french. English & French text showing fine for this content (using block region But after mouse hove to english & french, in english url a

  • Access the same page from multiple urls (wildcard)December 28

    I want to serve a specific Wordpress page for multiple urls. Basically I want to point all the urls in a specific format to a known page: /some-prefix-* => /target-page And accessing /some-prefix-and-here-something it should load /target-page. How to

  • Obey spaces with URL package (path command)December 12

    Background Using the \path command from the URL package to mark-up directory paths. Some of the paths have spaces. Problem The preamble is set to: \usepackage{algorithm} \usepackage{booktabs} % ... many other packages ... \usepackage[automark,noupper

  • Clean urls - auto path alias - how to remove accents (Á É Ó Í Ñ ) from the urls?November 3

    I´m using drupal 7.9 and pathauto 7.x-1.0-rc2 What I want is to remove the accents from the paths and replace them with normal letters Á=A É=E Ó=O Í=I Ñ=N etc, etc I'm using a taxonomy field type and node title to build the path [node:field_provincia

  • How can I get multisite primary blog (url or path) for current user?March 19

    In a multisite setup, when users are visiting a blog/site that there are not a member, I would like to display a link to "HOME" that takes them to their "primary" blog. I know how to determine if a user is or is not a member of a site

  • How can I get Views pages with taxonomy arguments display to fire after URL Alias (Path Auto)?December 25

    Right now I have a Views page that shows all results of the content type it filters by. If there is a taxonomy argument present (Contextual argument: Taxonomy ID: validate by Name to taxonomy ID) then of course it filter those results as specified. E

  • Do directory names and URL's paths make a difference for SEO?July 11

    Using a very simple example with cars, this seems to make more sense: site.com/cars/audi/convertibles/red/ But since a person is likely to search for red convertible or red audi convertible, would it be better to have: site.com/cars/red-audi-converti

  • Supplying current URL to "Path override" in Panels with Views paneJanuary 24

    Sorry if this is a known bug but I searched and couldn't find a related issue. I have a view which has a "Feed" display (xml), and a "Views Pane" display. On the "Feed" display the supplied path/URL for the display is "f

  • How to translate the URL alias (path) for an English version to an Arabic version?April 21

    I have a dual language site (English and Arabic). In the English version I added a URL alias: projects/commercial. But I can't find a way to have that translated to the Arabic version. I need that because the path is used by a breadcrumb module. Any

  • How to properly expand an argument to the \url or \path macro?

    How to properly expand an argument to the \url or \path macro?September 12

    In the following MSE: \documentclass{article} \usepackage{url} \newcommand{\rootDir}{\$ROOTDIR} \newcommand{\myDir}{my/dir} \newcommand{\makeFilePaths}[3]{% \expandafter\newcommand\expandafter{\csname dfile#1\endcsname}{% \rootDir/#2/#3% }% \expandaf

  • Handling bots that request URLs in pathsDecember 5

    In my server log, I found at least one IP address to be requesting a full URL in an awkward place. For example, the header the client sends to my server is this: GET http://www.3rdpartysite.com/file.php HTTP/1.1 And here, I'm expecting request header

  • Get url namespace path in DjangoFebruary 10

    I got those patterns: api_patterns = [ ... ] urlpatterns = [ url(r'^api/v1/', include(api_patterns, namespace='api')), ] I would like to get the 'api' namespace path in a view, so: api_path = ?????? # api_path = 'api/v1/' I've tried reverse function

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.440 s.