Any help with this would be great as I am struggling to get this to work.
I am trying to do a wildcard RedirectMatch 301 redirect for /pop.php?path=content/ using
RedirectMatch 301 /pop.php?path=content/.* http://mywebsite.com
But due to the ".", "?" and "=" is it not working correctly and I am not good with regular expressions.
Thanks
Steve
Put this in a .htaccess file in your site root:
RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} path=content [NC]
RewriteRule pop.php http://mywebsite.com/? [R=301,L]
You need the RewriteCond to inspect the value of the query string. If and only if it's a match, pop.php will be redirected to the other site.
Related
I want to redirect links containing characters like %C2%A0 on my htaccess file
example:
redirect 301 /actualite/presses-plieuses-electriques%C2%A0-les-5-criteres-de-choix_343.html https://www.mynewsite.com
is not working
redirect 301 /actualite/presses-plieuses-electriques-les-5-criteres-de-choix_343.html https://mynewsites.com
is working
How do I replace %C2%A0 and %E2%80%99 characters on mylinks ?
You can use this RewriteRule rule:
RewriteEngine On
RewriteRule ^actualite/presses-plieuses-electriques\xC2\xA0-les-5-criteres-de-choix_343\.html$ / [L,NC,R=301]
Note use of \xC2\xA0 for %C2%A0
I have to redirect urls like
www.site.com/?page=user?id=5
to something like
www.site.com/users/5
I wrote this regular expression
.*\?page=(.*)&id=(.*)
But it doesn't seem to work?
Full redirect rule:
Redirect 302 ^/.*index.php\?page=(.*)&id=(.*) /$1/$2
Redirect directive works on URL path only ie /index.php the part after ? is part of QUERY_STRING and it can not be matched using Redirect, You need to use mod-rewrite
RewriteEngine on
RewriteCond %{QUERY_STRING} ^page=([^&]+)&id=(.+)$ [NC]
RewriteRule ^index\.php$ /%1/%2? [L,R]
http://www.matthewsvolvosite.com/for...p?f=11&t=17479
Need to match and 301 redirect that. I've tried
RedirectMatch 301 ^/for\.\.\.p?f=11&t=17479$ /forums/viewtopic.php?t=17479
and
RedirectMatch 301 ^/for(.*)f=11&t=17479 /forums/viewtopic.php?f=2&t=17479
Neither work. I've searched and tried many examples. I'm at a loss.
The .htaccess file does match and redirect many other strings.
RewriteBase /
is active and working.
You need to use mod-rewrite
RewriteEngine on
RewriteCond %{QUERY_STRING} ^p=11&t=17479$
RewriteRule ^for\.\.\.p$ /forums/viewtopic.php?t=17479 [NC,L,R]
The reason why your redirect is not working is because you are using mod-alias to handle query strings .
I need to 301 redirect with a regular expression in the .htaccess file. it needs to from example.com/about-me/blog/anything-could-be-here/ to example.com/anything could-be-here
I got this but I know it is wrong, I'm new to this and not sure what else to do.
RewriteRule ^about-me/blog/($) [R=301] /$1
any help figuring out how to do this is much appreciated.
Your syntax and regex are incorrect.
You can use this RedirectMatch rule in your site root .htaccess:
RedirectMatch 301 ^/about-me/blog/(.*)$ /$1
Using mod_rewrite it will be:
RewriteEngine On
RewriteRule ^about-me/blog/(.*)$ /$1 [L,R=301,NC]
I need to have a redirect done to a site I have that is a 404 error.
Redirects are done in a .htaccess file for Joomla. This is what I have currently:
redirect 301 /?view=category&id=12:bestfriend&Itemid=946&start=20 http://www.mysite.com
But it doesn't redirect because it starts with a "?".
Any ideas? I have a number amount of these like this - not just one.
You cannot match query string using Redirect directive. Use mod_rewrite like this:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^view=category&id=12:bestfriend&Itemid=946&start=20 [NC]
RewriteRule ^ http://www.mysite.com/? [R=301,L]