ToddN
ToddN

Reputation: 2961

.htaccess 301 Redirecting old dynamic pages to static page

I looked through some other questions but no solutions seem to work. Here's a quick example of some 13k 301 redirects I must do. Here is one of which:

www.mysite.com/beta/index.php/cataloga/category/index.php?option=com_content&view=article&id=55&Itemid=3
to
www.mysite.com/applications/

So here's what I've tried:

Options +SymLinksIfOwnerMatch -Indexes
RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} ^option=com_content&view=article&id=55&Itemid=3
RewriteRule ^/beta/index.php/cataloga/category/index.php$ /applications/ [R=301,L]

RewriteRule /applications/ ^Itemid=3  [R=301,L]

RewriteRule ^Itemid=3 /applications/ [R=301,L]

RedirectMatch 301 ^/id=55&Itemid=3/.*$ /applications/

Redirect 301 /beta/index.php?option=com_content&view=article&id=55&Itemid=3 /applications/

EDIT Here is another sample URL I need to go to /compare/:

/beta/index.php/index.php/products/mysite/index.php/cataloga/category/index.php?option=com_content&view=article&id=37&Itemid=16

To check if Redirects were even working, I tested this and it worked fine:

Redirect 301 /beta/index.php/products/hyperpress /

Upvotes: 1

Views: 118

Answers (1)

anubhava
anubhava

Reputation: 784998

Try this rule:

Options +SymLinksIfOwnerMatch -Indexes
RewriteEngine On

RewriteCond %{QUERY_STRING} ^option=com_content&view=article&id=55&Itemid=3\b
RewriteRule (^|/)index\.php$ /applications/? [R=301,L,NC]

RewriteCond %{QUERY_STRING} ^option=com_content&view=article&id=37&Itemid=16\b
RewriteRule (^|/)index\.php$ /compare/? [R=301,L,NC]
  • Leading slash is not matched in htaccess
  • ? at the end of target URI will strip off query strings

Upvotes: 1

Related Questions