By blavish on
I have a problem, I want to remove the "node" from my pages without using pathauto. I have a lot of pages and I cant manually make a url for them using path module, there is just to many. But somewhere there must be a setting where can I change node to page? so that it dont say website.com/node/235235 but website.com/235235 or even change to node to page and get something like website.com/page/235235? Is there a file i can edit to do this? Pathauto is not compatible with my setup and I am not sure how to edit or change the node ?
Any help would be nice.
Thank you.
Comments
The 'node' part is hardcoded
The 'node' part is hardcoded in many places within drupal, so there's no way (aside from a mass find & replace!) to change this within the system.
If you really can't use pathauto, you could use some mod_rewrite trickery to rewrite/redirect the word 'page' to node. Something like:
This will transparently rewrite the url 'page/123' to 'node/123'. Users will not be aware of any difference, they will always see 'page/xxx'.
You could also do
to do a 'proper' redirect - users accessing 'page/123' will be redirected to 'node/123'.
This depends on your host running Apache and having mod_rewrite enabled. If either of the above result in a '500 Internal Server Error', check your logs - mod_rewrite may not be enabled.
Feel free to ask if you'd like me to explain the rewrited further.
Cheers,
Rob
Is this new rule supposed to
Is this new rule supposed to be placed after the standard index.php?q=$1 RewriteRule? I've been experimenting with every combination I can think of, and I can't acheive your first scenario:
which is precisely my end goal. I want to swap out node/page without running pathauto.
This is my .htaccess mod_rewrite block:
Am I nuts? Any thought or ideas about what I'm messing up?
Whoops...
Apologies, looks like the comment got posted twice...
???
If "website.com/page/235235" does what you want, then Pathauto can do that. Why is pathauto incompatible? Perhaps that's a more important question. You can always run pathauto once to bulk add URL aliases, then turn it off and manually add them after that.
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
See my related query,
See my related query, http://drupal.org/node/350296 -- I'm in a similar situation, but my concern is about the number of entries that will, in some circumstances, get added to url_aliases, and am wondering if there is another way to do this. I haven't yet tried using rewrite rules in Apache, but I may.
Jim, if I get this figured
Jim, if I get this figured out, I'll let you know. I read your other post and your reasoning is precisely the same as mine.
By the way, have you tried the rewrite logic above?
Maybe you should try the pathauto module (JUST KIDDING!)
I got the rewrite rule
I got the rewrite rule working, but... I'm starting to think it's a bad idea, and I'm going to go back to using url_aliases.
I modified the relevant part of the Drupal section of my httpd.conf file to look like this: (if you're doing this stuff in an .htaccess file, you'd do this there) --
That is, change car/whatever to index.php?q=node/whatever (the "true" url that Drupal is working with), stop processing rewrite rule (the "L"), and handle the affected stuff as a query string (the "QSA"). The important point is that the new rule goes BEFORE the other, "usual" rewrite rule. This rule works, in that it successfully takes a path like /car/123 and gets Drupal to show the path /node/123. It also works generally -- /car/123/action1 is correctly mapped to /node/123/action1, et al. So, yay, I guess.
So why am I worried? First, it's going to make my code look weird. The car_menu callback (already a mass of confusion for me) is going to be written differently than all the other modules in the world, since parts of it will be assuming the Apache rewrite rule. Second, the node_menu callback will need to be hacked (er, modified), since the "View" and "Edit" tabs will still be pointing to /node/123 and /node/123/edit. I could probably take care of that in car_nodeapi or something, but you get the idea -- it's patching stuff here and adding stuff there, when the original intent was to be simpler and cleaner. It's going to be pretty ugly, and, if anybody but me ever has to do anything with the code, I'm going to be worrying about its maintainability.
He who lives by the framework dies by the framework. I think this is one of those times when you grit your teeth and plan on a slightly bigger database server...
I follow exactly what you're
I follow exactly what you're saying. Since I spent too much time looking at this issue anyway, I took 5 more minutes to see how one might handle the issues that arise from using the rewrite logic (as you mention). At first glance this'll work, but if you're core-hack-resistant, as all good drupallers are, it becomes absolutely out of the question:
It'll probably break in some scenarios, but I'm not going to test it because I'm not going to use it. Heck, it might even cause as much overhead as path aliases (maybe not w/opcode caching). Just throwing it out there.
That live/die statement is so true. I've been checking out Kohana and CodeIgniter and I absolutely salivate over the speed... but there's SO MUCH that drupal does for me.
Hack the core? Moi?
Hack the core? Moi? Heavens no -- all those changes I've made are just ideas I'm testing out for submission to D7...
He he he!! Yes, all good
He he he!! Yes, all good drupallers here!
custom_url_rewrite is probably the answer
If anyone is still following this thread (or finds it in the future), I just discovered the custom_url_rewrite function -- http://api.drupal.org/api/function/custom_url_rewrite/5 (there are comparable versions for 4, 6, etc.). This did the trick for my exploding url_alias problem, and may be useful to others.