I have multi-url redirects and I need to make 301 redirects from?
RewriteRule ^car/([^/]+)/model-([^/]+)-([0-9]+)/$ new_car.php? model=$1&name=$2&year=$3 [QSA,L]
You can use the the following :
#1 301 redirect from the old location to the new
RewriteCond %{THE_REQUEST} /new_car\.php\?model=([^&]+)&name=([^&]+)&year=([^&\s]+) [NC]
RewriteRule ^ /car/%1/model-%2-%3/? [L,R=301]
#2 internally redirect from the new location to the old
RewriteRule ^car/([^/]+)/model-([^/]+)-([0-9]+)/?$ new_car.php? model=$1&name=$2&year=$3 [QSA,L]
Related
I have following pattern of URLs in some of my WordPress site
abc.com/xolo-lt900-price-in-india.html? m=1
and
abc.com/xolo-lt900-price-in-india.html? m=0
I want to remove part which is after parameter value and 301 redirect it to main/original URL.
So,
bc.com/xolo-lt900-price-in-india.html?m=1
Shall 301 redirect to
abc.comprice4india.co.in/xolo-lt900-price-in-india.html
And in same way
abc.com/xolo-lt900-price-in-india.html? m=0
Shall 301 redirect to
abc.com/xolo-lt900-price-in-india.html
I have the following code but its not working.
RewriteCond %{QUERY_STRING} m [NC]
RewriteRule ^$ /? [R=301,L]
Thanksfully the old code from #Anubhava is working now..
RewriteCond %{QUERY_STRING} ^m=[01]$ [NC]
RewriteRule ^(.*)$ /$1? [R=301,L,NC]
I have url
/en/parlour-profile/massage-parlour-anna-berry-massage-louise-sensual-massage%E2%80%8B
and I try
Redirect 301 /en/parlour-profile/massage-parlour-anna-berry-massage-louise-sensual-massage\%E2\%80\%8B /en
or
RewriteCond %{THE_REQUEST} ^\w+ /en/parlour-profile/massage-parlour-anna-berry-massage-louise-sensual-massage%E2%80%8B
RewriteRule ^ /en [R=301,L]
or
Redirect 301 /en/parlour-profile/massage-parlour-anna-berry-massage-louise-sensual-massage\%E2\%80\%8B /en
But any version don't work. How I can redirect from this url?
You can use this rule as your first rule in site root .htaccess:
RewriteEngine On
RewriteRule ^en/parlour-profile/massage-parlour-anna-berry-massage-louise-sensual-massage\xE2\x80\x8B/?$ /en? [L,NC,R=301]
\xMN is used in RewriteRule pattern to match %MN in URL.
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 want to redirect this please guide me
form
http://example.com/babycare/testimonials.php?id=7
to
http://example.com/babycare/testimonial/cat/1
To redirect
http://example.com/babycare/testimonials.php?id=7
to
http://example.com/babycare/testimonial/cat/1
You can use the following rule :
RewriteEngine on
RewriteCond %{THE_REQUEST} /babycare/testimonials\.php\?id=([0-9]+) [NC]
RewriteRule ^ /babycare/testimonial/cat/%1? [L,R]
I have recently changed CMS of my website and now looking to redirect old urls like:
oldpage.php?key=7cdb93c26
to some new urls but I want all of them in hard coded way and it should be a 301 redirect
I tried the following rules but none of them work for me
redirect 301 /oldpage.php?key=7cdb93c26 http://www.mynewsite.com/my-new-page.html
redirect 301 "/oldpage.php?key=7cdb93c26" http://www.mynewsite.com/my-new-page.html
RewriteRule ^oldpage.php?key=7cdb93c26$ http://www.mynewsite.com/my-new-page.html [L,R=301]
RewriteRule ^oldpage.php?key=7cdb93c26$ /my-new-page.html [L,R=301]
Try this
RewriteCond %{REQUEST_FILENAME} oldpage.php
RewriteCond %{QUERY_STRING} key=7cdb93c26
RewriteRule ^http://www.mynewsite.com/my-new-page.html [L,R=301]
I found the solution myself and here it is:
RewriteCond %{SCRIPT_FILENAME} oldpage.php
RewriteCond %{QUERY_STRING} key=7cdb93c26
RewriteRule ^(.*)$ http://www.mynewsite.com/my-new-page.html? [L,R=301]