I have a domain and two subdomains, each with it's own wordpress installation. I'd like to redirect the www to non-www for domain and the two subdomains. In its current form, my htaccess rules only work for the domain level.
I have these settings in my .htaccess file on domain level:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.electricmura\.ro [NC]
RewriteRule ^(.*)$ http://electricmura.ro/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www\.([^.]+\.electricmura\.ro)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
</IfModule>
But this only works for the domain level, not for the two subdomains.
www.electricmura.ro redirects to http://electricmura.ro/
www.mca.electricmura.ro/ gives a "We can't connect to the server" error (Firefox) or "www.mca.electricmura.ro’s server IP address could not be found." (Chrome)
Related
I have a site https://example.net
to ensure that all users go to the https:// I set up a redirect with APACHE (on the default.conf) as followed:
<VirtualHost *:80>
ServerName example.net
Redirect permanent / https://emalsys.net
# DocumentRoot /var/www/example.net/
<VirtualHost *:80>
My issue is when I try to access my phpmyadmin example.net/phpmyadmin I redirect to https://example.net/phpmyadmin and the page cannot be displayed.
(It is obviously working if I remove the Redirect).
How can I get avoid the redirect only for my phpmyadmin?
Any idea?
This is what I use in my servers to force HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
For other examples see Apache's wiki https://wiki.apache.org/httpd/RewriteHTTPToHTTPS
You can enter a REWRITECOND before a rewriterule:
REWRITECOND %{REQUEST_URI} !^http://www.example.com/phpMyAdmin
REWRITERULE / https://emalsys.net
A way around:
I do not know why but if I type as url example.net/phpmyadmin I will be redirected to https://example.netphpmyadmin/ but if I write https://example.net/phpmyadmin/ (with the /)I go to php my admin.
No idea why but I hope it will be of help to others.
to force https:// on pyp myadmin I added: $cfg['ForceSSL'] = true; at the end of phpMyAdmin’s config.inc.php file (see http://thebarton.org/forcing-ssl-with-phpmyadmin/).
We recently forced all pages to be HTTPS through .htaccess:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
The problem is that I get "Circular redirect path detected" from Facebook debugger because the original URL is https, but the og:url is http (so we don't lose all of our old likes), and then it gets a 302 loop back to https.
How can I make Facebook an exception to this .htaccess rule?
This question addresses the user-agent that facebook external hits will look like. You just need to add a condition to check for it:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_USER_AGENT} !facebookexternalhit/[0-9]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
I want to redirect my domain.com to openshift page (openshift-app.rhcloud.com). I've done it as described here and it works. The only problem is that on any site I won't be the address will always be domain.com. For example:
openshift-app.rhcloud.com -> domain.com
openshift-app.rhcloud.com/site1 -> domain.com
openshift-app.rhcloud.com/site2/subsite1 -> domain.com
All of those sites will redirect to domain.com. Is there any possibility to redirect it in a 'normal' way where entire address will be shown?
Add rule to .htaccess with 301 redirect for mod_rewrite:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^openshift-app.rhcloud.com$
RewriteRule (.*)$ http://www.domain.com/$1 [R=301,L]
Specifically for cartridge python-2.6 in folder ${OPENSHIFT_REPO_DIR}/wsgi/.htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^openshift-app.rhcloud.com$
RewriteRule ^application/(.*)$ http://www.domain.com/$1 [R=301,L]
I've finally resolved the problem. All I had to do:
Add aliases to openshift page (for www.mydomain.com and mydomain.com)
Add those rules to domain
mydomain.com. A <ip_address_to_openshift_page>
www A <ip_address_to_openshift_page>
mydomain.com. NS <dns_of_domain_provider>
For example (my domain is on linuxpl.com):
mydomain.com. A 107.22.142.72
www A 107.22.142.72
mydomain.com. NS ns15.linuxpl.com.
In apache configuration file (i.e., httpd.conf) we had virtual host configuration, which is working for last 2 years. Today to there no problem with it. But when I was asked to add redirection to it, it's not working. My virtualHost conatainer looks something like this
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName domain.com
Redirect 301 / http://www.domain.com/
Redirect 301 /index.html http://www.domain.com/
</VirtualHost>
Here when I'm typing "http://domain.com" it is taking to "http://www.domain.com" expected behaviour. But when I type "http://domain.com/index.html" or "http://www.domain.com/index.html" it is not taking me to "http://www.domain.com"...it is joomla website.
Can anyone resolve this for me...
Thanks in advance
Add
ServerAlias www.domain.com
in a new row after ServerName domain.com
It sounds like it's applying the first redirect before trying the second one.
Have you tried putting the Redirect lines in the other order?
Redirect 301 /index.html http://www.domain.com/
Redirect 301 / http://www.domain.com/
Usualy this is achieved by using a more general approach with mod_rewrite :
This code should be placed in the htaccess file in the root of your domain, i.e. domain.com/.htaccess
or the virtualhost configuration.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain\.com$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
</IfModule>
( e.g. also here Forcing the www prefix with PHP/htaccess/mod_rewrite )
I have a parkeddomain.com
It used to be a web application but I want any parkeddomain.com url to redirect to another domain
so
parkeddomain.com/signup would lead to anotherdomain.com
parkeddomain.com/page.php?q= would lead to anotherdomain.com
mod_rewrite:
RewriteEngine on
RewriteRule ^.*$ http://anotherdomain.com