Forum Moderators: phranque

Message Too Old, No Replies

Rewriterule with parameters

RewriteCond RewriteRule parameters

         

Ferraglia

8:51 am on Jul 19, 2007 (gmt 0)

10+ Year Member


Hello, I'm switching to a new CMS and I'd like to create an htaccess role to preserve search engines rank and 3rd site links to my pages.
Today users can reach article pages typing
article.php?sid=1130&mode=thread&order=0&thold=0
In the future I'd like that typing that url people will get access to
index.php?option=com_content&task=view&id=1130
NB
I'd like to get right results also if people will fit in the address url
article.php?mode=thread&order=0&thold=0&sid=1130 ("sid" param at the end of the url...)

Thanks if you can help me!
BR
Ferraglia

g1smd

12:09 pm on Jul 19, 2007 (gmt 0)

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



Which URL do you want to be indexed?

The old one or the new one?

.

If it is the new URLs, you'll need all internal site navigation to point to the new URLs, and set up a 301 redirect rule to redirect all requests for old URLs to their new version. The redirect caters for existing listings in the SERPs, existing incoming links, and stored bookmarks alike. There will be a brief loss of rankings as old pages are de-indexed and the new URL is re-indexed.

If it is the old URLs, you will need to set up an internal rewrite that pulls the new *filenames* from the server when you request the old *URLs*. You will also need to set up an external 301 redirect that redirects from the new "URLs" to the old URLs, otherwise you will have a duplicate content problem on your hands. There will be no loss of rankings.

Ferraglia

1:03 pm on Jul 20, 2007 (gmt 0)

10+ Year Member


Hi g1smd, and thanks for your reply.
I'd like to index the new one.
I tried something like that:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} ^sid=(.*)$
RewriteRule ^article\.php$ index.php?option=com_content&task=view&id=%1 [R=301,L]

...but without complete luck.
Have you got any solution?
BR
Ferraglia

Ferraglia

6:16 am on Jul 24, 2007 (gmt 0)

10+ Year Member


Any help about it?
BR
Ferraglia

jdMorgan

10:43 pm on Jul 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your RewriteCond will only match if the requested query string contains "sid=<anything>". That is, the requested query string *must* start with "sid=" or the rule will not run.

Also, the (.*) subpattern and back-reference will include *everything* that follows "sid=" -- including all the other query parameters if they are present.

I think you'd be happier with something like this:


RewriteCond %{QUERY_STRING} &?sid=([^&]+)
RewriteRule ^article\.php$ index.php?option=com_content&task=view&id=%1 [R=301,L]

It was not clear to me which was you new URL and which was your old. This code assumes that your new URL is "example.com/index.php?option=com_content&task=view&id=xyz"

Jim

Ferraglia

8:02 am on Jul 25, 2007 (gmt 0)

10+ Year Member


Thank you very much jdMorgan!
It's what I was searching for.
BR
Ferraglia