i have a subdomain lets say http://coding.designzzz.com/ i want to redirect it to http://www.designzzz.com/tag/coding/
What i am looking forward to is whatever the further url in the subdomain i want it to land on www.designzzz.com/tag/coding/
A few redirects i tried were having this behavior.. if coding.designzzz.com/abc.html is run they were redirecting it to www.designzzz.com/tag/coding/abc.html.. i just want the urls to redirect to www.designzzz.com/tag/coding/ and not the preceding urls/page.
And yes 301 redirects.
Help is appreciated.
Thank you very much
You can use this rule:
RewriteCond %{HTTP_HOST} ^coding\.designzzz\.com$ [NC]
RewriteRule ^ http://www.designzzz.com/tag/coding/? [L,R=301]
Related
I need to make the following redirection using htaccess (WordPress)
http://oldweb.com/pl/
to https://newweb.com/url/differenturl/
But this redirection should work only for http://oldweb.com/pl/, the urls http://oldweb.com/en/ or http://oldweb.com/il/ should not have any redirection.
My solution works but it works for /en/ and /il/ also:
Redirect 301 http://oldweb.com/pl/ https://newweb.com/url/differenturl/
I'm not a hero in rewriting, sorry :) Can anyone help me with this simple thing?
Redirect matches only REQUEST_URI not full URL with domain protocol etc.
Better to use a RewriteRule just below RewriteEngine On line in your root .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?oldweb\.com$ [NC]
RewriteRule ^pl/?$ https://newweb.com/url/differenturl/ [L,NC,R=301]
Hello!
Please help me!
I have a main domain "domain.com"
And i have a subfolders
--folder_one
--folder_two
--folder_three
--folder_four
...
How can i, using, htaccess, redirect users from http://example.com to https://example.com and if user going to any subfolder in this domain redirect him to http of this, Example: https://example.com/folder_one to https://example.com/folder_one
I have done this, but i get a permanent redirect.
Please help.
Many thanks!
This redirect main domain to http and subfolders to https. I want exactly the opposite
RewriteCond %{HTTP_HOST} !^example\.com$ [NC,OR]
RewriteCond %{HTTPS} on
RewriteRule ^ http://example.com%{REQUEST_URI} [NE,R=301,L]
htaccess 301 redirect. I have this old site which is for example http://test.org/conference I want to redirect it to conference.test.org
What happened is the 301 redirect in my .htaccess file is quite buggy.
Here is my 301 redirect htaccess code below:
RewriteCond %{REQUEST_URI} ^/http://test.org/conference(/)?
RewriteRule ^(.*)$ http://conference.test.org/? [R=301,L]
When I test this one it runs and redirects correctly. But when I test it over and over again. It seems not to redirect anymore.
Can someone help me have a htaccess 301 redirect code?
Any help is much appreciated.TIA
I assume this is what you are looking for:
RewriteEngine on
RewriteRule ^conference/?$ http://conference.test.org/ [R=301,L,QSA]
Please note that %{REQUEST_URI} only contains the path of the URI, so not the protocol and the hostname. Reason is that the evaluation is performed inside a http host. This is explicitly pointed out in the documentation: http://httpd.apache.org/docs/current/mod/mod_rewrite.html
Depending on your http hosts setup you might also have to add a condition to prevent an endless redirection loop:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^conference\.test\.org$ [NC]
RewriteRule ^conference/?$ http://conference.test.org/ [R=301,L,QSA]
But usually that is not required, since the rule should be defined inside the test.org http host...
I don't even know how to ask this question correctly, because I have never seen it done before. I am pretty competent with editing name servers, creating a records, and cnames etc, but I have no idea if this is even possible.
I have a client that owns a several domains that all point at the same site. So say the main domain is www.client-site.com. So then www.other-domain-1.com and www.other-domain-2.com are simply set as 301 redirects to point at www.client-site.com.
So all is good until now he is requesting that www.other-domain-1.com/facebook and www.other-domain-1.com/linkedin point to his facebook page or linkedin profiles instead of redirecting to the main domain.
The 301 redirect is happening at the registrar, and I don't believe there is a way to do what he wants from there. But I am thinking I could instead point it at the web host nameservers and include it as a addon domain, and then use the .htaccess file to do the 301 redirect of only the hostname, and then redirect as desired the hostname/paths.
So what is the proper way to do this? Something like...
Redirect 301 http://other-domain-1.com/facebook http://facebook.com/account
Redirect 301 http://other-domain-1.com/linkedin http://linkedin.com/profile
Redirect 301 http://other-domain-1.com http://client-site.com
You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
# facebook redirect
RewriteCond %{HTTP_HOST} ^(www\.)?other-domain-1\.com$ [NC]
RewriteRule ^facebook/?$ http://facebook.com/account [L,NC,R=302]
# linked-in redirect
RewriteCond %{HTTP_HOST} ^(www\.)?other-domain-1\.com$ [NC]
RewriteRule ^linkedin/?$ http://linkedin.com/profile [L,NC,R=302]
# rest of the redirects
RewriteCond %{HTTP_HOST} ^(www\.)?other-domain-1\.com$ [NC]
RewriteRule ^ http://client-site.com%{REQUEST_URI} [L,NE,R=302]
So the Solution that worked on my server based on anubhava answer above was
facebook redirect
RewriteCond %{HTTP_HOST} ^(www\.)?other-domain-1\.com$ [NC]
RewriteRule ^facebook/?$ http://facebook.com/account [L,NC,R=302]
Then after getting them all working changed the R=302 to R=301 to make the redirects permanent.
I want a user who made request from example.com to mydomain.example/domains to redirect to mydomain.example/userdomain. It is like implementing vanity URLs as per the user's domain name.
I know, we can do it using .htaccess redirect rules but don't know how to do.
I've EDITED the following code as best I can without a way to test it. It should get you close if it doesn't work.
RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
RewriteRule ^/(.*) http://%1/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteRule ^/(.*) mydomain.example/%1/$1 [L]
should do the trick. Can't test it quickly myself though. There are two key things to notice:
You gotta use HTTP_HOST in a RewriteCond to test the domain. Use %1 in the RewriteRule line to get the variable from the HTTP_HOST line in parentheses.
You also gotta redirect any requests to www to the non www with an R=301 permanent redirect first. It might be possible NOT to do this, but I'm not sure at the moment how to extract the non www part of the host regardless of its presence. The R=301 sends a redirect msg back to the browser for anyone who visits www.example.com. Then the browser will hit example.com and your second RewriteRule will match against it. Since its 301 (permanent) the browser will cache the redirect and always do the non-www for the user on its own.
If this doesn't work, compare to some other tutorials on URL redirection and also refer to this wonderful page:
http://httpd.apache.org/docs/2.2/rewrite/intro.html