Forum Moderators: phranque
RewriteEngine OnRewriteRule ^tags/(.*)$ e107_plugins/tagcloud/tagcloud.php?$1 [L]
Now I want to redirect visitors from old url to new. I tried the following line:
RewriteRule ^e107_plugins/tagcloud/tagcloud.php?(.*)$ /tags/$1 [R,L]
Thanks
No. That's not what it does. You're looking at it back to front.
It takes a URL request for example.com/tags/<something> or for www.example.com/tags/<something> and rewrites the request to internally fetch the content from /e107_plugins/tagcloud/tagcloud.php?<something> instead of where the URL suggests that it might be stored.
.
R makes a 302 redirect. Use R=301 instead.
A redirect should include the domain name in the target URL.
RewriteRule cannot see parameters. Use an additional RewriteCond looking at QUERY_STRING here.
RewriteEngine On
RewriteBase /RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /e107_plugins/tagcloud/tagcloud\.php\?([^&]+)\ HTTP/
RewriteRule ^e107_plugins/tagcloud/tagcloud\.php$ http://mysite.com/tags/%1? [R=301,L]
RewriteRule ^tags/(.*)$ e107_plugins/tagcloud/tagcloud.php?$1 [L]
Thanks for the help. Its a great forum.
I would also insert a general site-wide non-www to www 301 redirect after that specific 'parameter' redirect, and before the rewrite, to fix up all of the other non-www URLs on the site.
RewriteBase / is the default and can usually be omitted. Oh, and the reason the initial code didn't work is because it created an infinite redirect - rewrite - redirect - rewrite - etc loop. The fix was for the redirect to be invoked only for direct client requests (by examining THE_REQUEST).