Hi there,
Thanks you for this absolutely critical and brilliant module.

I have an odd use case, but maybe of interest to others...

I am totally rebuilding an ancient HTML site with thousands of pages. (!) In the process I am of course creating redirects for the old URLS.

I would like to be able to create a view of all redirects similar to the one created by the module (admin/config/search/redirect) but with my own extra filters (i.e. only certain node types) and some extra fields, i.e. the node title, an image field, etc. so that they are easy to locate and look at the old version for comparison.

Any suggestions?

Thanks again,
Katharine

Comments

Katharine_Gates created an issue. See original summary.

chaseontheweb’s picture

I've had times when I've wanted something like that: a way to join a redirect row with its associated node/entity.

Probably the closest you could get today would be to:

  • Make a view of content "A".
  • Make a view of redirects "B" with Redirect URL as a contextual filter.
  • Within A, use views_field_view to add a View field.
  • Set the View field's contextual filter to "node/[nid]".

The downside of this approach is that you couldn't filter on just nodes with redirects associated.


A more appropriate approach would be to have a relationship handler along the lines of "Content: Redirects on node". What you'd end up with is a query like this:

SELECT *
FROM `redirect` r, `node` n
WHERE r.redirect = CONCAT('node/', n.nid)

Which, while that does work (at least in MySQL), is horribly slow even for queries with a low limit (in my case, 0.653s vs. 0.001s for 50 rows). I didn't even explore whether it's possible to make a Views relationship handler use a CONCAT.

More practical from a performance standpoint would be to have a redirect_entity_index table used to directly map a redirect to its destination entity. I think our usecase is kind of niche, so I wouldn't expect such a feature to actually make it into the module.

katharine_gates’s picture

Thank you so much for this! Mainly I really just need to see a list of nodes that do NOT have redirects so I can make sure we don't have too many "Page not Found" messages.

Any ideas?

chaseontheweb’s picture

Category: Feature request » Support request

I don't think the redirect module itself could used for the purpose of finding nodes without redirects. What it does offer is a 'Fix 404 pages' tab so that you could spot fix broken URLs after going live.

Assuming what you want is a one-time report of all aliased nodes that do not have redirects, you could use an ugly query like this in MySQL:

SELECT ua.alias FROM node n
LEFT JOIN url_alias ua ON ua.source = CONCAT('node/', n.nid)
LEFT JOIN redirect r ON r.redirect = CONCAT('node/', n.nid)
WHERE r.rid IS NULL
AND ua.pid IS NULL
AND n.type='page';

Again, it's very slow (for me, 22 seconds for ~2000 rows). But, for a one-time report, you could use phpMyAdmin or Adminer to generate a CSV spreadsheet from that query, define redirects in the spreadsheet for ones that need them, then use path_redirect_import to quickly bring them in.