I have a dynamic url domain.com/product/Paper_Bags/Merchandise_Bags_-_Matte_Colors/6_25__X_9_25_/Misty_Grey?7. Which when called need to redirect to domain.com/paper-merchandise-bags-plain-white/
I am using the condition and the rule as
RewriteCond %{QUERY_STRING} (.*)$
RewriteRule ^(.*)/Misty_Grey http://domain.com/paper-merchandise-bags-plain-white/? [R=301,L]
But its not working. Can Someone help me to solve this issue.
If i use RedirectMatch ^(.*)/Misty_Grey http://domain.com/paper-merchandise-bags-plain-white/
Its getting redirected to http://domain.com/paper-merchandise-bags-plain-white/?7
Is there any way to remove the ?7 so tha the querystring will not be visible
Try the following commands,
//Rewrite to www
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com[nc]
RewriteRule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
//301 Redirect Old File
Redirect 301 http://domain.com/product/Paper_Bags/Merchandise_Bags_-_Matte_Colors/6_25__X_9_25_/Misty_Grey?7 http://domain.com/paper-merchandise-bags-plain-white/?
Related
I have a subdomain called es and I need when someone wants to enter mysite.com/es it can be redirect to es.mysite.com. It works with the following htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.mysite.com$ [NC]
RewriteRule ^(.*)$ http://es.mysite.com/$1 [R=301,L]
RedirectMatch permanent ^/es/?$ http://es.mysite.com/$1
The problem is when someone types mysite.com/es/bla/bla/bla. In this case, with the current configuration on my htaccess, the user isn't redirected and I want the user can be redirected.
For example:
If I enter:
http://letsbonus.com/es/barcelona/spa-experiencie-para-2-opcion-masaje-desconecta-roc-nature-273710
This is redirect to:
http://es.letsbonus.com/barcelona/spa-experiencie-para-2-opcion-masaje-desconecta-roc-nature-273710
Thanks in advance.
You need just this one rule in your root .htaccess of mysite.com:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?(mysite\.com)$ [NC]
RewriteRule ^es/(.*)$ http://es.%1/$1 [R=301,L,NE]
Your two rules enter into conflict:
Base url: http://example.com/es/test
Non-www redirection -> http://www.example.com/es/test
es subdomain redirection -> http://es.example.com/test
Non-www redirection... (we're no longer under www subdomain)
I would use this htaccess to get the excepted result:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www|es).example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteRule ^es/(.*)$ http://es.example.com/$1 [R=301,L]
I am updating the Iirf.ini file to redirect sub.columbia.edu to giving.columbia.edu/video.
sub.columbia.edu is already redirecting to giving.columbia.edu.
How can I go one step further to redirect it to giving.columbia.edu/video.
Important Note: I would like the URL to show as sub.columbia.edu in the browser and not as giving.columbia.edu/video
#Redirect subdomain to specific URL
RewriteCond %{HTTP_HOST} ^sub\.columbia\.edu
RewriteRule ^/$ /video
The above doesn't work. Any ideas how I should modify this?
Thank you!
You can try this and see how it works for you.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub\.columbia\.edu
RewriteRule ^(.*) http://giving.columbia.edu/video [L,R=301]
Or you can do a redirect, this should work also.
Redirect 301 / http://giving.columbia.edu/video
I have a condition for url redirect like,
www.domain.com/something/anotherthing/index.php
i need the above url to redirect to
www.domain.com/something/anotherthing/
If i go to
www.domain.com/index.php/something/anotherthing
i want to redirect to
www.domain.com/something/anotherthing
i have a redirect htaccess rule for this
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index.php$1 [NC]
RewriteRule ^ /%1$1 [R=301,L]
But this works for the first condition but in the later it redirect me to the root page. Can anyone please help in this redirection.
Thanks in Advance.
Try something like this:
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index.php/?([^\ \?]*) [NC]
RewriteRule ^ %1/%2 [R=301,L]
That should handle any location of /index.php.
I'm attempting to redirect some rewritten URL's but while the redirect is working, it is including the original parameter before the rewrite.
e.g. Redirect /used-cars.html http://www.odins.co.uk/our-cars.html
The rewritten URL is based upon the following structure:
http://www.domain.co.uk/pages/index.php?p=used-cars
However, what is happening is this:
http://www.domain.co.uk/our-cars.html?p=used-cars
The .htaccess file is as follows:
Options -Indexes
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^odins.co.uk [NC]
RewriteRule ^(.*)$ http://www.odins.co.uk/$1 [L,R=301]
RewriteRule ^([^/]*)\.html$ /pages/index.php?p=$1 [L]
RewriteRule ^news/([^/]*)$ /pages/news/index.php?n=$1 [L]
Redirect /used-cars.html http://www.domain.co.uk/our-cars.html
Any help would be appreciated.
Paul
I am finding some problems in the htaccess of CMS with a 301 redirect.
When trying to solve canonical urls (redirecting site to www.site) I got the problem that I cannot log in in the back end (www.site/admin).
The htaccess condition is:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.site\.co.uk$
RewriteRule (.*) http://www.site.co.uk$1 [R=301,L]
I guess I need to include a expression that allows the URI /admin not to be redirected, but how?
Like this, for example:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !=www.example.co.uk
RewriteCond %{REQUEST_URI} !^/admin
RewriteRule .* http://www.example.co.uk%{REQUEST_URI} [R=301,L]