0

Have looked at all the other posts regarding this, but can't seem to get it to work. There are a number of unrelated reasons why I can't change the Joomla config, items, etc., but in any event, it seems that these should work regardless of that.

In short, I want any link with Itemid=30 in it to redirect to the one given. What am I doing wrong? The first 3 are what I've tried, that last line is one that is working.

RedirectMatch 301 ^Itemid=30$ http://inside.beta.oursite.com/index.php?option=com_cware&view=courses&Itemid=125

redirect 301 index.php?option=com_cware&view=courses&Itemid=30 http://inside.beta.oursite.com/index.php?option=com_cware&view=courses&Itemid=125

RewriteEngine On
RewriteCond %{QUERY_STRING} Itemid=30
RewriteRule ^Itemid=30/$ index.php?option=com_content&view=article&id=106&Itemid=121 [R=301]


# If query string contains "username=admin"
RewriteCond %{QUERY_STRING} username=admin
# Block it without mercy
RewriteRule .* - [F]
4

1 回答 1

1

Redirect considers only URL paths, which excludes the query string. If you want to take the query string into account, you must employ mod_rewrite.

Same applies to RewriteRule

If you wish to match against the hostname, port, or query string, use a RewriteCond with the %{HTTP_HOST}, %{SERVER_PORT}, or %{QUERY_STRING} variables respectively.

Therefore, if you want to match some query string and redirect all URLs to some other URL, use a RewriteCond in combination with RewriteRule

RewriteEngine On
RewriteCond %{QUERY_STRING} Itemid=30
RewriteRule .* index.php?option=com_content&view=article&id=106&Itemid=121 [R=301]

This redirects any URL .* with the query string containing Itemid=30 to index.php?option=com_content&...

于 2013-03-04T22:03:30.957 回答