htaccess mod rewrite url with adding up & parameter in url - .htaccess

We have a specific section of games called com_games. Could someone advise on how to rewrite url by adding parameter of & through htaccess so as have 301 redirect
From
http://www.abc.com/?page=4&option=com_games&view=list&Itemid=2
to
http://www.abc.com/?page=4&&option=com_games&view=list&Itemid=2
This needs to be achieve in all pagination pages, How to append & in the url for 301 redirection

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/\?(page=[^&]+)&([^&][^\s]+)\s [NC]
RewriteRule ^ %{REQUEST_URI}?%1&&%2 [R=301,L]

Related

Subdomain URL 301 redirect to non-subdomain

I have some subdomain URL's that I would like to 301 redirect to a new non-subdomain URL, could someone give me one example on how to do this so I can apply it to my other URL's.
The .com/url will vary quite a bit
Old URL:
http://products.mysite.com/klim--siteassign-Snowmobile--_n-96
New URL:
http://www.mysite.com/klim.html
Thanks
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^products\.mysite\.com$ [NC]
RewriteRule ^([^-]+)-.*$ http://www.mysite.com/$1.html [L,R=301,NC]

Cannot 301 redirect this page to a specific page

I want this page:
http://mystore.com/Login.aspx?ReturnUrl=%2fPages%2fHome%2fUser%2fWish-list.aspx
to
http://mystore.com/en/ukeurope/home
So, I try to write a 301 redirection rule like this:
RewriteRule ^Login.aspx$ en/ukeurope/home? [R=301,L]
but when I want to try this redirection.
It gives me 404 not Found.
P.S. I don't want another one that is
mystore.com/Page/Login.aspx
to be redirected by this 301 redirection rule
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+Login\.aspx?ReturnUrl=\%2fPages\%2fHome\%2fUser\%2fWish-list\.aspx [NC]
RewriteRule ^ /en/ukeurope/home? [R=302,L]

How to make htaccess rule for a URL with specific characters?

I need to 301 redirect all ?print=yes URLs to the URLs without ?print=yes that contain the same name in them through .htaccess. Currently the button to PRINT is present in the header of the website so it's more than 70 URLs to fix... Removing the button to PRINT the page will ruin the design quite a bit, so it's not really an option.
I think it needs to be a RedirectMatch rule, but how do I write it?
Example: redirect 301 from domain.com/faq/?print=yes to domain.com/faq
Thanks in advance!
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^print=yes$ [NC]
RewriteRule ^ %{REQUEST_URI}? [R=301,L,NE]
I am not sure if redirect can do the same but here is how I would do it with rewrite
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\?print=yes$ $1 [NC]

.htaccess rule to rewrite calls from subdomain to amazonaws

I am looking to rewrite all calls to
subdomain.domain.com/video.mp4
to rewrite to
https://s3.amazonaws.com/whatever/video.mp4
How would I do that?
And this is for embedded calls in video players/scripts...
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com$ [NC]
RewriteRule ^(.+)$ https://s3.amazonaws.com/whatever/$1 [R=301,L]
Assuming you have a dedicated folder for the subdomain, you would just need the following rule:
RedirectMatch 301 /(.*) https://s3.amazonaws.com/whatever/$1

Special characters in mod_rewrite url

I want this URL:
http://www.mydomainblabla.com/s/can+you+drill+shrinky+dinks?.html
to be rewritten to this one:
http://www.mydomainblabla.com/search.php?q=can+you+drill+shrinky+dinks?
I am using this mod_rewrite rule in my .htaccess to accomplish this
RewriteRule ^s/(.+).html$ search.php?q=$1 [L,QSA]
However, the result is not as I want it, when I go to the first url, I get a page not found message.
The same problem occurs when I visit this url:
http://www.mydomainblabla.com/s/http://www.zakgeldnodig.nl/.html
which should be rewritten into this one:
http://www.mydomainblabla.com/search.php?q=http://www.zakgeldnodig.nl/
What modifications should I make to my .htaccess to make this work?
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+s/(.+?)\.html [NC]
RewriteRule ^ search.php?q=%1 [L,NE]

Resources