I am trying to redirect from the following URL concepts into a 301 redirect URL but keep failing (doesnt seem to be working).
/blahblah?area=something
to
www.newdomain.com/blahblah/
I have tried the following but it did not working
Redirect 301 /blahblah.php/\?area=something www.newdomain.com/blahblah/
You can use this rule in your root .htaccess:
RewriteEngine On
RewriteCond %{THE_REQUEST} /blahblah\.php/\?area=something [NC]
RewriteRule ^ /blahblah/$ [R=302,L]
Related
I tried the following code in .htaccess to 301 redirect www.example.com/?content=file.php&id=16 www.example.com/file/This-is-the-title/16
RewriteEngine on
Redirect 301 /?content=file.php&id=16 /file/This-is-the-title/16
But it's not redirecting. The URL remains as it is.
What am I doing wrong?
P.S. I'm not asking for rewrite or so. I need a 301 redirect.
The Redirect directive doesn't match query strings. Use this instead:
RewriteEngine on
RewriteCond %{QUERY_STRING} =content=file.php&id=16
RewriteRule ^$ /file/This-is-the-title/16? [R=301,L]
I need the solution for home page 301 redirection.
If I enter like below url in the browse bar
http://www.starmed.dk/index.php/component/restaurantguide/tags/tags/2-kebab?sem_midx=-3&sem_jidx=-1
http://www.starmed.dk/index.php/about-us/restaurant/faq.php
http://www.starmed.dk/index.php/about-us/tags/18-pizzeria
http://www.starmed.dk/index.php/about-us/tags/9-online-shop
http://www.starmed.dk/index.php/tilfoj-din-butik/city/47-odder?sem_midx=-1&sem_jidx=-3&format=feed&type=atom
http://www.starmed.dk/index.php/component/restaurantguide/recipes/recipes/20-ca-nuong-trui-bare-fried-fish?sem_midx=3&sem_jidx=1
http://www.starmed.dk/index.php/tilfoj-din-butik/city/95-kalundborg?sem_midx=-6&sem_jidx=0
http://www.starmed.dk/index.php/component/restaurantguide/restaurant/1-frederiks-have?sem_midx=2&sem_jidx=1
http://www.starmed.dk/index.php/tilfoj-din-butik/tags/faq.php
http://www.starmed.dk/?index%5c.php%25253Fid=3-yorkshire-savings-account.83&xzaty=3&article=83
http://www.starmed.dk/?option=com_restaurantguide&view=states&id=450:midtjylland
http://www.starmed.dk/index.php?cPath=56
http://www.starmed.dk/index.php?cPath=25
http://www.starmed.dk/index.php?cPath=47
and etc...
If I enter after index.php some values like mentoned above example
then it will be redirected to http://www.starmed.dk without index.php
How to do this using HTACCESS 301 redirect common rule?
You can use this rule to remove index.php from your URL:
RewriteEngine On
# remove index.php, MAKE SURE THIS IS YOUR FIRST RULE
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteCond %{REQUEST_URI} ^(.*/)index\.php$ [NC]
RewriteRule ^ %1 [L,R=301,NE]
I wanted to make a 301 from URL with ?mobile=N parameter to URL without that parameter. Google is indexing this URL and I think that 301 is the best way to fix that
eg.
FROM
www.example.com/?mobile=N
TO
www.example.com
FROM
www.example.com/example/example.com?mobile=N
TO
www.example.com/example/example.com
You can use in your .htaccess:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^mobile=N$ [NC]
RewriteRule ^ %{REQUEST_URI}? [R=301,L]
I'm using something similar to the following:
RewriteEngine on
Redirect 301 / http://newdomain.co.uk/link/
Redirect 301 /showcase.asp?showcaseid=1 http://newdomain.co.uk/track1
Redirect 301 /showcase.asp?showcaseid=2 http://newdomain.co.uk/track2
Redirect 301 /showcase.asp?showcaseid=3 http://newdomain.co.uk/track3
Redirect 301 /showcase http://newdomain.co.uk/link/tracks
With that in mind any URL other than the mentione would go to http://newdomain.co.uk/link
Which is fine however any of the other URL's that use a "?" go to say http://newdomain.co.uk/link/showcaseid=1 for /showcase.asp?showcaseid=1
Also with the
Redirect 301 /showcase http://newdomain.co.uk/link/tracks
can I just write as follows:
Redirect 301 /showcase tracks
You can't match against the query string (everything after the ?) in a Redirect directive. You have to use mod_rewrite's %{QUERY_STRING} variable:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^showcaseid=([0-9])
RewriteRule ^showcase\.asp$ http://newdomain.co.uk/track%1 [L,R=301]
RewriteRule ^showcase$ http://newdomain.co.uk/link/tracks [L,R=301]
RewriteRUle ^$ http://newdomain.co.uk/link/ [L,R=301]
Note that the order is important. You generally want the more general matching rules to be at the end.
A new website has just gone live and there is a htaccess file which has 301 redirects in order to direct people from the old pages on the old domain to the new pages on the new domain.
However, because there is a ? and = symbol in the links it's not working.
I understand I'll need to take advantage of the query string, but I can't work out how to get these three examples working.
Redirect 301 /index.cfm?task=what_we_do http://domain.com/services/
Redirect 301 /pagecontent/_newsitem.cfm?newsid=63 http://domain.com/name-of-article/
Redirect 301 /pagecontent/_people.cfm?peopleid=3 http://domain.com/about-us/meet-the-team/john-smith/
Can anyone help?
You can't use a query string in the redirect. you have to use mod_rewrite.
RewriteEngine On
RewriteCond %{QUERY_STRING} ^task=what_we_do$
RewriteRule ^index.cfm http://domain.com/services/? [R=301,L]
RewriteCond %{QUERY_STRING} ^_newsid=63$
RewriteRule ^pagecontent/_newsitem.cfm http://domain.com/name-of-article/? [R=301,L]
RewriteCond %{QUERY_STRING} ^_peopleid=3$
RewriteRule ^pagecontent/_people.cfm http://domain.com/about-us/meet-the-team/john-smith/? [R=301,L]