Forum Moderators: phranque

Message Too Old, No Replies

.htaccess: dynamic link to dynamic link

         

werci

1:30 am on Oct 26, 2009 (gmt 0)

10+ Year Member



hi,

i tried so hard but i cant figure out, how i'm gonna do redirect dynamic link to dynamic link.. I wanna redirect

folder/game?comp=ven&game=354089

to

folder/game.php?comp=ven&game=354089

g1smd

7:41 am on Oct 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Query strings are re-appended automatically, so the rule will probably only need to specify the folder and file part of the URL (though it might need to test the query string value if there are others that should not be processed).

One big question, do you really mean 'redirect' or do you mean 'rewrite'?

What is the URL that the user sees and uses? What is the filename inside the server?

If this were my site, the URL would look like

example.com/folder/ven/354089
or
example.com/folder/game/ven/354089
.

werci

3:56 pm on Oct 26, 2009 (gmt 0)

10+ Year Member



users see:
[#*$!.com...]
but this link doesn't work because i changed link system and it has to be like that: `http://#*$!.com/folder/game.PHP?comp=ven&game=350751`.. So links useless right now and i cant change all links manually. i want when user enter this link: `...game?comp=ven&game=350751` link will become `...game.PHP?comp=ven&game=350751` like that..

i hope you understand me..

jdMorgan

4:43 pm on Oct 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When a user enters a URL or clicks on a link, the server resolves that to a filepath. So it does not "change a link to a link," but rather may change a requested URL to a non-default filepath. URLs and server filepaths are very different things; They are not at all equivalent, but only 'assoicated' by the action of the server.

Your problem should be quite easy to fix using mod_rewrite, with a rule of the form:


RewriteRule ^pattern-to-match-requested-URL-path$ /actual-server-filepath [L]

For example,

RewriteRule ^foo\.html$ /bar\.php [L]

will rewrite client requests for the URL example.com/foo to the script at filepath /bar.php, and will pass any query string unchanged.

If you don't have any other working RewriteRules, you will need to precede that RewriteRule with either both of these lines or only the second line. You will have to test to find out, because it depends on your server configuration.


Options +FollowSymLinks
RewriteEngine on

Please see our Forum Charter for useful references and information about how to get the most from this forum.

Jim