Redirect Permanent strange behaveiour hot to fix??

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
akronim

Redirect Permanent strange behaveiour hot to fix??

Post by akronim »

Hi I need to redirect permanently - 301 pages from an old site to a new CMSMS

I used a rewrie rule to redirect all the pages corsi.php?id=$  to the new page corsi.html
this rule works with the simple url corsi.php, but when i put corsi.php?id=1 the result is corsi.html?id=1  ???

don't know hot to manage this ???

this is my htaccess.

Code: Select all

#php_flag magic_quotes_gpc Off
#php_flag register_globals Off
#php_flag session.use_trans_sid Off

# Make sure you have Options FollowSymLinks
# and Allow on
RewriteEngine On

RewriteRule ^corsi\.php*$ http://www.studioarteceramica.it/corsi.html [R=301,L]

#Rewrites page.shtml as index.php?page
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
any help ?
unknown

Re: Redirect Permanent strange behaveiour hot to fix??

Post by unknown »

Ahhh. You are so close.

Try this:

Code: Select all


RewriteRule ^(.+)$ corsi.php?id=$1 http://www.studioarteceramica.it/corsi.html [R=301,L]


Just replace your old 301 line with the one above and leave everything else as is.

I'll keep an eye on the thread in case you still run into trouble.

Good Luck. :)
akronim

Re: Redirect Permanent strange behaveiour hot to fix??

Post by akronim »

unfortunally that rule does not work on my server :(  Apache 1.3.37

It generates a 500 Internal Server Error

??? ??? ???
Pierre M.

Re: Redirect Permanent strange behaveiour hot to fix??

Post by Pierre M. »

What about this one :

Code: Select all

RewriteRule ^corsi\.php?id=$1 http://www.studioarteceramica.it/corsi.html [R=301,L]
Or may be ^/corsi ?

Pierre M.
unknown

Re: Redirect Permanent strange behaveiour hot to fix??

Post by unknown »

OK.
Let's dedug this a bit. :)

Run this up the flag pole:

Code: Select all


RewriteRule ^corsi.php?id=$1 corsi.html [R=301,L]

This assumes that everything comes out of the root folder. If it were a simple file operation,
it'd be as simple as:

Code: Select all


RewriteRule ^SomeFileName.html$ OtherFileNameWithDifferentExtension.phtml [R=301,L]

But in your case, we're attempting to trap the:

Code: Select all


?id=<something-not-yet-known>

Anyway, here's hoping. I'll give it more thought in case this attempt should fail.

Best wishes.


Wait a momment!

My first suggestion was correct. But I forgot that I need to regex everything after the id=.
So all I need to know is whether they're numbers [0-9], or letters [a-x|A-Z].
Although both can be done simultaniously. It's easier when only having to deal with 1. :)
unknown

Re: Redirect Permanent strange behaveiour hot to fix??

Post by unknown »

Followup to my previous post...

To better illustrate what I meant in my last comment; one needs (in your case) to trap any request
that follows your

Code: Select all

id=
An example out of one of my domains configs:

Code: Select all


RewriteRule ^([A-Z0-9]+[A-Za-z0-9]*)/*$ index.php?webname=$1  moved.php [R=301,L]

My example is slightly modified so as to appear closer to your intended target. I used this one to
better illustrate the regex I was referring to in my last comment.

Another example that I use all the time, is "short hand" (why I use it all the time.) :)
Goes like this:

Code: Select all


Redirect 301 /oldfilename.php http://host.domain.tld/newfilename.php

Naturally, it isn't limited to file names. It can just as easily be filename > completely different domain.
Also note the omission of the regex.

Something I often find myself referring to for memory refreshment is a cheat-sheet. I'll (attempt) to attach
it to this post. With as many threads started over mod_rewrite. This attachment (or post) should probably
get "pinned". For quick-and-easy reference. :)

Well, here goes. Let's see if I can attach these goodies. :)

OK. It seems that I can't attach the mod_rewrite cheat sheet. I get an error message that the image
is too biig (in bytes). So I'll only be able to post the regex cheat sheet. I could compress it into an
archive so it is small enough. But archives are not an allowed attachment. Bummer. :(

Well. Hope this helps. :)
Attachments
regular_expressions_cheat_sheet.png
Locked

Return to “CMSMS Core”