Forum Moderators: phranque

Message Too Old, No Replies

Noob with Re-Write question

please help.

         

BRSalazar

4:11 pm on Aug 15, 2006 (gmt 0)

10+ Year Member



Hello. I am very new to this type of thing and hope someone can help.

I have an old site that was running on PHPnuke. I created a new site based on Joomla to replace the old site. However, I kept the olr site in another directory. I have many dynamic links set up to the old site urls. I am wondering if there is a way to redirect to the new dir, based on the querie strings?

Current site is
www.example.com

Old site is
www.example.com/archive/

The old site article strings all were like so...
http://www.example.com/index.php?name=News (and then different queries)

They are still intact but need to be...
http://www.example.com/archive/index.php?name=News ...

Because the new site is based on a different CMS, I don't have to worry about that same querie coming through for the new articles. So can I redirect any of the old links to this new directory?

Is this possible, and if so how?

Thank you in advance for any help.

[edited by: jdMorgan at 9:25 pm (utc) on Aug. 15, 2006]
[edit reason]
[1][edit reason] Example.com [/edit]
[/edit][/1]

Psychopsia

4:59 pm on Aug 15, 2006 (gmt 0)

10+ Year Member



RewriteEngine on

RewriteRule ^index\.php\?name=(.*)$ /archive/index.php?name=$1

jdMorgan

5:28 pm on Aug 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Query strings are handles separately, so the code above won't work. Also, the request was for a redirect, and the code above performs an internal rewrite.

I'd suggest:


RewriteEngine on
RewriteCond %{QUERY_STRING} ^name=([^&]+)
RewriteRule ^index\.php$ http://www.example.com/archive/index.php?name=%1

Jim

BRSalazar

7:15 pm on Aug 15, 2006 (gmt 0)

10+ Year Member



Hmm, neither appear to be working.

Is it possible that the ReWrite Engine is not working? Is there a way for me to test that.

Once again, thanks for all help.

BRSalazar

7:34 pm on Aug 15, 2006 (gmt 0)

10+ Year Member



Nevermind, it's working like a charm. Thanks you so very much!

BRSalazar

7:43 pm on Aug 15, 2006 (gmt 0)

10+ Year Member



Well almost. It appears to be working, except it takes any old link to the archive, but only to the home page. It won't go any further, even if I click on the internal links from there.

jdMorgan

11:23 pm on Aug 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



We have no idea what your URL-structure looks like, or what one of these non-working URLs looks like. As a result, it's rather hard to discern what changes might be needed.

Jim

BRSalazar

10:44 pm on Aug 17, 2006 (gmt 0)

10+ Year Member



I'm very sorry. Thank you for your patience.

Here is an example of a basic link URL

http://www.example.com/index.php?name=News&file=article&sid=7978

Basically, I need it to redirect to this

http://www.example.com/archive/index.php?name=News&file=article&sid=7978

But I need it to be dynamically generated.

I hope that helps.

[edited by: jdMorgan at 1:56 pm (utc) on Aug. 18, 2006]
[edit reason]
[1][edit reason] No URLs, please. See Terms of Service. [/edit]
[/edit][/1]

jdMorgan

1:57 pm on Aug 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can you please specify which parts of your requested URL are fixed and which can change? Without knowing that, it's impossible to suggest anything, given only one example URL.

Just annotate the URL showing what parts are variables:

Example:

Rewrite /<script>.php?name=<name>&file=<file>&sid=<sid> --> /archive/<script>.php?name=<name_val>&file=<file_val>&sid=<sid_val>
or
Rewrite /<script>.<script_type>?name=<name>&file=<file>&sid=<sid> --> /archive/<script_val>.<script_type_val>?name=<name_val>&file=<file_val>&sid=<sid_val>

Also, the more time I must spend editing posts for TOS violations, the less time I have to answer questions, and many members here won't answer posts with TOS violations in them... Please review the edits made to your posts above. Thanks.

Jim

BRSalazar

5:45 pm on Aug 21, 2006 (gmt 0)

10+ Year Member



Very sorry once again.

Basically, there are two typers of urls

article --> http://www.example.com/index.php?name=News&file=<var>&sid=<var>

and category
http://www.example.com/index.php?name=News&catid=<var>

Is that what you are lookig for?

jdMorgan

9:39 pm on Aug 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> Is that what you are looking for?

Well, I hope so... :)


RewriteEngine on
RewriteCond %{QUERY_STRING} ^name=News&(file=[^&]+&sid=[b][^&]+¦catid[/b]=[^&]+)
RewriteRule ^index\.php$ http://www.example.com/archive/index.php [L]

This will detect the two query string cases you cited, and rewrite requests for index.php to the /archive subdirectory with the original query string intact.

Inportant: Replace the broken pipe "¦" character in the RewriteCond pattern (in the highlighted area) above with a solid pipe character before use (just re-type it); Posting on this forum modifies the pipe character.

As long as the name/value pairs are in the stated order, this should work. If they are not always in the same order, then the solution gets complicated (but still possible).

Jim

BRSalazar

10:18 pm on Aug 21, 2006 (gmt 0)

10+ Year Member



it appears to be working perfectly. Thank you so very much. I really appreciate all the help, and putting up with my ignorance. Thanks again!

BRSalazar

5:41 pm on Aug 22, 2006 (gmt 0)

10+ Year Member



Okay, I guess things are a bit more complicated.

It appears the previous ones a re working just fine, but there are multiple queiries for the same article. It looks as if this also exits.

http://example.com/modules.php?op=modload&name=News&file=article&sid=<var>

and it would need to look like this...

http://example.com/archive/modules.php?op=modload&name=News&file=article&sid=<var>

Can I just add another ReWrite Cond and Rule?

BRSalazar

5:51 pm on Aug 22, 2006 (gmt 0)

10+ Year Member



Nevermind, I believe I figuresd it out. I added this...

RewriteCond %{QUERY_STRING} ^op=modload&name=News&file=article&(sid=[^&]+)
RewriteRule ^modules\.php$ http://www.example.com/archive/modules.php [L]

and it seems to be working now.