Assistance Please on Rewrite

 
Post new topic   Reply to topic    Aprelium Forum Index -> URL Rewriting
View previous topic :: View next topic  
Author Message
cenocre
-


Joined: 12 Mar 2007
Posts: 47

PostPosted: Tue Mar 03, 2009 2:51 am    Post subject: Assistance Please on Rewrite Reply with quote

I need to change part of a URL from:

This:

http://DOMAIN/cgi.pan~MORE_PARAMETERS

needs to become:

http://DOMAIN/cgi-bin/Panorama.cgi?PanoramaCGI~.cgiDispatch~MORE_PARAMETERS

therefore this:

cgi.pan

gets changed to:

cgi-bin/Panorama.cgi?PanoramaCGI~.cgiDispatch


Is this what I should do?

"cgi.pan" in "Virtual Path Regular Expression"
with no conditions
internal redirection
"cgi-bin/Panorama.cgi?PanoramaCGI~" in Redirect To
append query string checked

Should anything else be checked?
Back to top View user's profile Send private message
anybody
-


Joined: 17 Mar 2008
Posts: 90

PostPosted: Tue Mar 03, 2009 7:02 am    Post subject: Reply with quote

Do you have any experience with mod_rewrite and apache? If you do then I suggest writing your rewrites in a htaccess file and using TRUSTAbyss' AWS:MRT to translate it to abyss. It saves me allot of time and it works rather well.
Back to top View user's profile Send private message
pkSML
-


Joined: 29 May 2006
Posts: 952
Location: Michigan, USA

PostPosted: Fri Mar 06, 2009 3:10 pm    Post subject: Re: Assistance Please on Rewrite Reply with quote

cenocre wrote:
I need to change part of a URL from:

This:

http://DOMAIN/cgi.pan~MORE_PARAMETERS

needs to become:

http://DOMAIN/cgi-bin/Panorama.cgi?PanoramaCGI~.cgiDispatch~MORE_PARAMETERS

therefore this:

cgi.pan

gets changed to:

cgi-bin/Panorama.cgi?PanoramaCGI~.cgiDispatch


Is this what I should do?

"cgi.pan" in "Virtual Path Regular Expression"
with no conditions
internal redirection
"cgi-bin/Panorama.cgi?PanoramaCGI~" in Redirect To
append query string checked

Should anything else be checked?


Virtual path: ^/cgi.pan$
internal redirection to:
/cgi-bin/Panorama.cgi?PanoramaCGI~.cgiDispatch
append query string

That would be my guess!
_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
cenocre
-


Joined: 12 Mar 2007
Posts: 47

PostPosted: Sun Mar 08, 2009 11:20 am    Post subject: Reply with quote

Thanks to both of you. I tried the script with a simple test to no avail.

I decided to try a very simple string with no unusual characters and convert:
http://domain.com/this/index.html
to
http://domain.com/that/index.html


Virtual path: ^/this$
internal redirection to:
/that
append query string (also tried unchecked)

It didn't work. I've tried various combinations of checkboxes and nada - there is no change to the URL at all. Sigh - this should be a no brainer.

Any ideas?
Back to top View user's profile Send private message
cenocre
-


Joined: 12 Mar 2007
Posts: 47

PostPosted: Sun Mar 08, 2009 1:04 pm    Post subject: Strange Behavior Reply with quote

I tried a variation:

Virtual path: /this
internal redirection to:
/that
append query string

The URL briefly flashed with "//////////" after the .html and then stayed as it originally was with "too many redirects".

So, I tried:

Virtual path: /this/
internal redirection to:
/that/
append query string

and got an error 500

then:

Virtual path: this
internal redirection to:
that
append query string

and got an "too many redirects"
Back to top View user's profile Send private message
pkSML
-


Joined: 29 May 2006
Posts: 952
Location: Michigan, USA

PostPosted: Mon Mar 09, 2009 1:16 am    Post subject: Reply with quote

cenocre wrote:
Thanks to both of you. I tried the script with a simple test to no avail.

I decided to try a very simple string with no unusual characters and convert:
http://domain.com/this/index.html
to
http://domain.com/that/index.html


Virtual path: ^/this$
internal redirection to:
/that
append query string (also tried unchecked)

It didn't work. I've tried various combinations of checkboxes and nada - there is no change to the URL at all. Sigh - this should be a no brainer.

Any ideas?


Ah, yes, this one should be easy to solve. Don't you hate banging your head over something so simple? I seem to do that quite frequently when coding.

First of all, the query string is everything after the ? in a URL. It's not telling Abyss which script to run, but rather variables that help configure the script.
Secondly, understanding regular expressions is the ultimate bane of all newbie scripters. I've spent much time at http://regular-expressions.info. It's very helpful.

So, here's the solution for your simple query:

http://domain.com/this/index.html --> http://domain.com/that/index.html

Virtual path: ^/this/(.*)$
internal redirection to: /that/$1
append query string


Everything matched between the two parenthesis is held in the $1 variable.

PS If you could give me more example URLs that you want converted for Panorama, I'm sure I or someone else could get you rolling.
_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
cenocre
-


Joined: 12 Mar 2007
Posts: 47

PostPosted: Mon Mar 09, 2009 1:56 am    Post subject: Reply with quote

Your this/that example worked. Thank you.

I hate this kind of time waster. I've been programming professionally for about 20 years and even did some stuff in CP/M86 and have found this to be the most frustrating. Some supposedly simple mod_rewrite stuff took months of probing to get a decent answer.

As for Panorama, this is the only change that we need to do and is the same for all sites:

cgi.pan

gets changed to:

cgi-bin/Panorama.cgi?PanoramaCGI~.cgiDispatch~

cgi.pan example - look at the URL after doing a search at: http://www.naturephotocentral.com/Open_Vocabulary.html

Panorama.cgi example - look at the URL after doing a search at: http://www.rogerwadestudio.com/Open_Vocabulary.html

Thanks again.
Back to top View user's profile Send private message
pkSML
-


Joined: 29 May 2006
Posts: 952
Location: Michigan, USA

PostPosted: Tue Mar 10, 2009 7:00 pm    Post subject: Reply with quote

cenocre wrote:
cgi.pan

gets changed to:

cgi-bin/Panorama.cgi?PanoramaCGI~.cgiDispatch~


From the example sites you gave, you should know that this rewriting is quite an advanced (and weird!) system. It will probably take a lot of tweaking to get it working just right.

Try this:
virtual path regex: ^/cgi.pan(.*)
case-sensitive: unchecked
conditions: (none)
apply to subrequests: checked
internal redirection to: /cgi-bin/Panorama.cgi?PanoramaCGI~.cgiDispatch~$1
append query string: checked
escape redirection location: checked
next action: continue with next rule

Also, when you see the table of URL rewrite rules, click 'edit', right next to 'advanced parameters'. Start a log file and check 'log variables'.

If you run into trouble, check out your url rewrite logfile -- it will show you exactly what the parsing engine was doing. Be sure to keep an eye on the size of this file as it can grow very quickly!
If you need more help, include at least one example from the url rewrite file. You can post it on the code-bin if you want to. (That's one of my Abyss-hosted websites!)
_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
cenocre
-


Joined: 12 Mar 2007
Posts: 47

PostPosted: Tue Mar 10, 2009 8:56 pm    Post subject: Reply with quote

I had already figured it out and tried your last idea. It almost works, but changes the $ just AFTER the changing string to &.

Here is the log output. The ampersand in front of "bjphoto" started out as a dollar sign and should NOT have been changed. That appears to be the only issue.

Quote:
Rule #1: Regex [^/cgi.pan(.*)$] matches with the request URI

Matching results:

$0=/cgi.pan

$1=

Replacing the virtual path with [/cgi-bin/Panorama.cgi] => /cgi-bin/Panorama.cgi

Adding the query string replacement [?PanoramaCGI~.cgiDispatch~$1] => /cgi-bin/Panorama.cgi?PanoramaCGI~.cgiDispatch~

Appending the original query string => /cgi-bin/Panorama.cgi?PanoramaCGI~.cgiDispatch~&bjphoto

===> Internal redirection to /cgi-bin/Panorama.cgi?PanoramaCGI~.cgiDispatch~&bjphoto

Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> URL Rewriting All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group