Forum Moderators: phranque

Message Too Old, No Replies

redirect dynamic url

         

siMKin

12:32 pm on Aug 18, 2005 (gmt 0)

10+ Year Member



I found this post [webmasterworld.com ] with a similar question, but back then, nobody seemed to know the answer. hopefully, now someone does :)

I want to redirect something like this:
http:/www.domain.com/subdir/file.php?a=1&b2
to
http:/www.domain.com/another_subdir/another_file.php?mode=sth&a=1&b2

does anyone know how to do this?

quickstudy

2:07 pm on Aug 18, 2005 (gmt 0)

10+ Year Member



I would suggest that you use mod rewrite.

if you place the following in your .htaccess and place it in the root of your website.
(I haven't tested it)

RewriteEngine on
rewriteBase /
rewriteRule ^subdir/file\.php\?(.*) /another_subdir/another_file.php\?mode=sth&$1

assuming that you don't know of mod rewrite:
start by reading:
<snip>
[google.dk...]
and use
[httpd.apache.org...]
as reference.

I hope it helps

/Kasper

[edited by: jdMorgan at 2:10 pm (utc) on Aug. 18, 2005]
[edit reason] Snipped .com URL. [/edit]

jdMorgan

2:31 pm on Aug 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check out mod_rewrite using RewriteCond to test the query string and RewriteRule using the [QSA] flag.

More refererences are available in our forum charter and in the library (links are at the top of each page here).

Jim

siMKin

10:41 am on Aug 22, 2005 (gmt 0)

10+ Year Member



I've read what is says in the library and experimented with a very simple case. I put this:

RewriteEngine on
RewriteBase /
RewriteRule ^dir1/file1\.php dir2/file2\.php

in my .htacess, but it doesn't work. I get an error 500 (internal server error)
What's more, every page-request is now converted into a 500 Internal Server Error :-(
I'm obviously doing something very stupid, but i don't know what.

jdMorgan

1:28 pm on Aug 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The first place to look when you get a server error is in your server error log. Debugging this stuff can be very difficult without doing so.

I'll take a guess, and suggest that you try this:


Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^dir1/file1\.php$ /dir2/file2.php [L]

It may be that you're not allowed to use mod_rewrite on that server. Again, your error log will tell you.

Jim

siMKin

7:42 am on Aug 23, 2005 (gmt 0)

10+ Year Member



RewriteEngine not allowed here

That's pretty clear :(

And the server is not mine, so i can't change my permissions.

Is there any other solution to my problem that does not require this RewriteEngine?