homepage Welcome to WebmasterWorld Guest from 54.198.42.105
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
mod rewrite - redirecting from url with query string
codeman




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

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!

 

jdMorgan




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

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

codeman




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

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

jdMorgan




msg:3543464
 7:55 pm on Jan 8, 2008 (gmt 0)

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

codeman




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

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"

jdMorgan




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

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

Jim

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

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