I have some dupilcate pages in my Joomla site.
Examples
/80-games
/80-games?start=12
/80-games?start=20
I did a 301 redirect in my .htcaccess for the first one which works fine.
My redirect for /80-games
Redirect 301 /80-games http://www.teach-this.com/esl-games
But for /80-games?start=12
The url changes to http://www.teach-this.com/esl-games?start=12
What should my redirect be for /80-games?start=12
Somehow the question mark is causing my destination url to change.
Thanks
Paul
You should use mod_rewrite as you cannot manipulate QUERY_STRING using mod_alias rules.
Put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^80-games/?$ http://www.teach-this.com/esl-games? [R=301,L,NC]
Note ? at the end of target URI that is used to strip out any existing QUERY_STRING in the original URL.
Related
i have a couple of unwanted urls that i want to redirect:
/faq/
/faq/question/1-title
/faq/question/2-title
I want all the /faq/question/* urls to redirect to /faq, is that possible?
I have this but this doesnt work :
RedirectMatch 301 ^/faq/question/([^/]+)/?$ /faq
With your shown samples/attempts, please try following htaccess rules file. Make sure you are putting this new rule at top of your htaccess file(after https rules(to change http --> https rules) in case there are any present in your htaccess file).
Also make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
##Put your new rule here..
RewriteRule ^faq/question/ /faq? [R=301,L,NC]
###Make sure to keep rest of your urls here onwards...
So i have this issue, with changing an old site with a new and I need to redirect all the old links. So have this:
domain.com/articles.php?var=1
I basicly want to redirect everything after articles.php to just domain.com, including the /articles.php.
Thank you in advance.
Try adding this to your htaccess file:
RedirectMatch 301 ^/articles\.php$ /
or if you have mod_rewrite rules already in your htaccess file, you need to use mod_rewrite isntead, and add this rule above whatever rules are already there:
RewriteRule ^articles\.php$ / [L,R=301]
I want to redirect certain urls matching a pattern to the site root.
I'm doing:
RedirectMatch 301 ^/ABCDE.*$ /
But whenever there is a ? in the url the resulting link is whatever is after the url. How can I redirect also urls including questionmarks?
To strip off existing query string you need to use mod_rewrite rules. Put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^ABCDE.*$ /? [L,R=301,NC]
I need to redirect all the old URLs on my site to new URLs, but am having issues. A given URL and its subfolders need redirecting to the same page.
For example, this is the first one:
redirect 301 /panache/sports-bra/ http://www.newdomain.co.uk/sports-bra.html
This works ok. However there are these size sub-pages which need to redirect to the same location:
redirect 301 /panache/sports-bra/30DD http://www.newdomain.co.uk/sports-bra.html
redirect 301 /panache/sports-bra/30E http://www.newdomain.co.uk/sports-bra.html
redirect 301 /panache/sports-bra/30F http://www.newdomain.co.uk/sports-bra.html
And these don't work, I end up at a location like the following:
http://www.newdomain.co.uk/sports-bra.html30DD
See the way the last part of the path is appended to the url? I'm guessing it's because the second redirect is conflicting with the initial 301 redirect?
I have also tried using this rewrite rule but have had no luck. The site is Magento so I don't know if this has some effect? mod_rewrite is enabled on the server.
RewriteRule ^panache/sports-bra/ http://www.newdomain.co.uk/sports-bra.html [R=301]
Any help mucha ppreciated.
Try this.
RewriteEngine on
RewriteRule ^(panache/sports-bra/.*)$ /sports-bra.html [L,R=301,NC]
I'm having a problem with my htaccess, we've moved a website and they're old website had a lot of duplicate pages that had a ?cat_id=88 etc... on them, I'm trying to redirect the page but it's not working, I've put the redirect code below, I'm already redirection the mantra.html to the /Mantra but the version with the ?cat_id=79 isn't redirecting, it's just ignoring everything after the ?
Redirect 301 /mantra.html?cat_id=79 http://www.website.co.uk/Mantra
Redirect only accepts paths, not paths with querystring. You could use mod_rewrite
RewriteEngine on
RewriteCond %{QUERY_STRING} ^cat_id=79$
RewriteRule ^mantra\.html$ /Mantra? [R=302,L]
change 302 to 301 once you get it working (301 are aggressively cached by browsers and make debugging a nightmare).
EDIT added a ? at the end to remove any querystring. Apache removes the ? if there is no other data in the querystring, so the end user will never see it.