I know how to redirect from:
http://domain.com to https://www.domain.com
and
http://www.domain.com to https://www.domain.com
but not how to redirect from:
https://domain.com to https://www.domain.com
I am using on the virtual server for port 80 : (this works fine)
RedirectMatch 301 ^/$ https://www.domain.com
RedirectMatch 301 ^(.*)$ https://www.domain.com
RedirectMatch 301 ^http://domain.com/$ https://www.domain.com
I tried using on the virtual server port 443, but it does not work.
Redirectmatch 301 ^https://domain.com/ https://www.domain.com
You would need to have a certificate that matches domain.com, as well as your standard www.domain.com certificate, since you can't redirect until after an SSL channel has been established.
Most people wouldn't think it was worth the expense of obtaining two certificates for each domain, just to achieve a redirect. A Wildcard certificate wouldn't help here (I believe), since I think all domains covered by a wildcard cert have to be at the same level (e.g. *.domain.com would be valid for www.domain.com and www2.domain.com, but not for just domain.com)
Related
Today I installed the SSL certificate in my GoDaddy hosting account.
Everything seems to work when I type "https://myDomain.co.il, meaning, my website is secured.
But when I type HTTP://myDomain.co.il, my website is not secured.
As I was looking for an answer to solve this problem, I found an article in GoDaddy that explains how to redirect HTTP to https.
Is says that I need to open a file inside public_html called .htaccess.
Inside the file, I wrote the following code:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www\.)?coolexample\.com
RewriteRule ^(.*)$ https://www.coolexample.com/$1 [R,L]
Unfortunately, it's not working.
Another question, when I'll solve this problem, if I will type www.myDomain.co.il or myDoamin.co.il, will it redirect to https as well?
i am trying to redirect all subdomains with more than 2 letters :
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^([^\.]{2,})\.domain\.com$ [NC]
RewriteRule .* index.php?page=static&subject=%1 [L,QSA]
for example : about.domain.com to display content of domain.com/?page=static&subject=about
but the URL remains about.domain.com in the browser
as well as if you're on about.domain.com and requested another page on that domain ( all pages go through index.php?page=blablabla) you need to be redirected back to domain.com/(whatever requested)
Same-domain internal rewrites can be done with the [P] (proxy) option.
If you need to reverse proxy a URL from the same virtual host config, you might be able to get away with a [P] rule, but if the domain of the internal request is from a different virtual host (or on a different box entirely) you probably need to look at a ProxyPass config.
In either case you will need mod_proxy installed and enabled.
My question is regarding RewriteMap on apache2: I want to apply a rewrite condition, so that all request on my proxy are proxied to an completely new domain.
Eg localhost/test or any other url should just go to www.mydomain.com:
RewriteRule / http://www.mydomain.com [P]
Works fine. If I access localhost, I still see "localhost" in my browser address line, but mydomain.com is presented. BUT if I now click on any link on this mydomain site, I will get a "Not Found" response.
The sourecode of mydomain contains eg this link:
Link
If I access the site in a normal way, this would result in: www.mydomain.com/lab/sale.php, and works fine.
If I access the site through my proxy and the rewriteRule takes place, I would after the link click be directed to: localhost/lab/sale.php, which does not exist of course.
Question: how can I a user that accesses the site through my proxy browse on the whole site as if he would really access this site?
The RewriteRule directive isn't like a ProxyPass or Redirect where they essentially link 2 nodes together and everything following it also gets proxied. The rule that you have only proxies the request URI /, not /lab/ or /etc.php or anything else. You need to create a match and pass that along as a backreference:
RewriteRule ^/?(.*)$ http://www.mydomain.com/$1 [P]
Or you can use the %{REQUEST_URI} variable:
RewriteRule ^ http://www.mydomain.com%{REQUEST_URI} [P]
The following is generating a lot of traffic but it's not for me.
Or they try to break in or they are voting for a house number, not sure.
Log:
POST /?xclzve_ty4AGLRXcipv06CINTZekrx28EKPVb HTTP/1.1
GET /?xclzve_lsx27CHMRWbglrw16BHMRWciou05AF HTTP/1.1
Is it possible to redirect to a 404 page or block ?xclzve_* (?xclzve_ is the same but the number or line behind it is different)
Try putting this in the htaccess file in your document root (or your vhost config)
RewriteEngine On
RewriteCond %{QUERY_STRING} xclzve_
RewriteRule ^ - [F,L]
This will return a 403 Forbidden, or you can replace F, with R=404 for a 404 not found.
Though you may want to block the IP address(es) that these requests are coming from? If it's just one or two, you can do:
Order Allow,Deny
Deny From 123.45.67.89
if 123.45.67.89 is one of the IP's sending bogus requests. It may be a tad faster than using the rewrite engine.
I want to redirect www.mydomain.com/store to http://store.anotherdomain.com/me
When I use RewriteRule ^store$ http://store.anotherdomain.com/me it ends up redirecting, meaning the URL changes, rather than remaining www.mydomain.com/store
What do I need it to do to do the rewrite properly?
When I use RewriteRule ^next$ /mydomain/subfolder/subfolder/subfolder is seems to work fine.
RewriteRule ^store$ http://store.anotherdomain.com/me [P]
Note the [P] at the end. You'll also need to have the mod_proxy module enabled.
You don't need mod_rewrite at all.
You need to enable mod_proxy and configure a reverse proxy. You can even pass cookies from the other domain and make them look as if they were from your site.
ProxyPass /store/ http://store.anotherdomain.com/me/
ProxyPassReverse /store/ http://store.anotherdomain.com/me/
ProxyPassReverseCookieDomain store.anotherdomain.com www.mydomain.com
ProxyPassReverseCookiePath /me/ /store/