Last updated August 10, 2006.
I'll be migrating Kairosnews from PostNuke to Drupal CVS this weekend. Since the site has almost 2000 stories, I'm concerned about the fact tha any links to them from around the web will go dead. Some consolation is that the .htaccess rules will take those dead links and refer them to the home page instead of 404ing them.
Can .htaccess be configured to rewrite the urls? The node ids will be taken from the current story id's, so that part will not be a problem.
The current PN default story url looks like this:
modules.php?op=modload&name=News&file
=article&sid=1972&mode=nested&order=0&thold=0
so it seems like it could be rewritten to
node/view/1972
Is this possible? Admittedly, I know very little about mod_rewrite. Any suggestions would be helpful.
Comments
Try this
Something like this should work:
RewriteRule ^modules.php?op=modload&name=News&file
=article&sid=([1-9][0-9]*)* node/view/$1
----------------
Mr PHP :: Professional Website Services
re: Try this
Thanks so much! It would have taken me quite a few hours to figure that out. I'll try it out on Saturday :)
-----
Charlie Lowe | cyberdash
Tips for posting to the Drupal forums
This works for me with Drupal 4.6.x
[Updated 2006-01-19]
I could not get the above RewriteRule to work. After som trial and error I come up with the following rules. They will rewrite the syndicate link and really old "...article&sid=123" links also.
# Rewrite PN legacy URLsRewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/backend.php
RewriteRule ^backend.php /rss.xml [R=permanent,L]
RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^op=modload&name=News&file=article&sid=([1-9][0-9]*)*$
RewriteRule ^modules\.php /node/%1? [R=permanent,L]
RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^sid=([1-9][0-9]*)*$
RewriteRule ^article\.php /node/%1? [R=permanent,L]
The "?" after "%1" stops the query string from being attached to the URL.
Start from those in the .htaccess file
It is possible. Take a look at the
mod_rewriterules that are part of the.htaccessfile that ships with Drupal; it should be fairly straightforward to alter these.