Welcome to WebmasterWorld Guest from 50.16.24.12

Forum Moderators: Ocean10000 & incrediBILL & phranque

mod rewrite - redirecting from url with query string

   
4:43 pm on Jan 8, 2008 (gmt 0)

5+ Year Member



Hi,

I am looking for the correct .htaccess entry to redirect from:

/band/index.cfm?fuseaction=home.audio

to:

http://www.example.com/audio

Any help would be greatly appreciated!

5:48 pm on Jan 8, 2008 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Is this a one-off, or are you looking for a general solution?
And just to be clear, you want to stop using cold fusion for this page and use a static file to serve it instead?

(I'm asking because if you are looking for a general solution to using search-engine-friendly URLs for dynamically-generated files, then what you've requested is actually backwards).

Jim

6:39 pm on Jan 8, 2008 (gmt 0)

5+ Year Member



Hi JD,

This is a one-off situation. The site has already been re-written in PHP from ColdFusion, and can now take advantage of SEO-friendly URL's...oh, and the DNS transfer is about to take place! ;-)

There are only about 8 dynamic URL's in the old site (it is not a huge ecommerce thing by any means), so it will be straightforward enough to just write a rule for each url. So, theoretically I am looking for someting along these lines, although I know that this is not correct because mod_rewrite cannot interpret the query string this way:


Redirect 301 /band/index.cfm?fuseaction=home.audio h**p://www.examplesite.com/audio
7:55 pm on Jan 8, 2008 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



That, and "Redirect" is a mod_alias directive, not mod_rewrite... :)

You will need mod_rewrite to do this. The first two directives are only needed if you don't already have working mod_rewrite code in this .htaccess file. The first may not be needed at all, or it may be required. Only testing can determine this, since server configurations vary.


Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{QUERY_STRING} ^fuseaction=home\.audio$
RewriteRule ^band/index\.cfm$ http://www.example.com/audio [R=301,L]

Jim
8:07 pm on Jan 9, 2008 (gmt 0)

5+ Year Member



Hi JD,

Thanks for your reply, this looks perfect, but yet it is not working, i just get a 404 at the old URL. Maybe it has something to do with the existing rewrite rule? Here's what I have:


RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} ^fuseaction=home\.audio$
RewriteRule ^band/index\.cfm$ h**p://www.example.com/audio [R=301,L]

RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^(.*)$ index.php/$1/ [L]

If this looks ok, it might have something to do with the PHP framework that the site is built with...The second rule you see above is what allows the PHP framework to generate SEO-friendly URL's...otherwise they would look like "/index.php/audio"

4:31 am on Jan 10, 2008 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Quick question: Did you completely flush your browser cache before testing the new code?

Jim

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved