Using file .htaccess, i would like to redirect from http://example.com to http://example.com/en, when i get to http://example.com
Put this code in your root .htaccess file
RewriteEngine On
RewriteCond %{HTTP_HOST} !^example\.com
RewriteRule (.*) http://example.com/en/$1 [R=301,L]
Related
i have website with this domain example.com and have file like this example.com/example.php how to redirect all file to other website there have same domain name but different in extension
so it will redirect example.com/example.php to example.net/example.php with htaccess?
Thanks so much!
Try this:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !newdomain.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]
I moved my site from blog.abc.com to www.abc.com
I want to redirect every request made to blog.abc.com to abc.com
For example:
If blog.abc.com/example.html is requested, it should redirect to www.abc.com/example.html, how can I do it via .htaccess only?
You can put this code in your htaccess (in blog.abc.com root folder)
RewriteEngine On
RewriteCond %{HTTP_HOST} ^blog\.(.+)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
Using mod_rewrite you could do it like this:
RewriteEngine On
RewriteCondition %{HTTP_HOST} ^blog.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R,L]
or if blog.example.com has its own vhost you could also use mod_alias:
Redirect / http://example.com/
Basically I want sub.domain.com to redirect to domain.com, but only that url. For example sub.domain.com/page should still load without redirecting. How can I do this .htaccess?
Your .htaccess should look like
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^sub\.domain\.com$ [NC]
RewriteCond %{REQUEST_URI} ^/?$
RewriteRule .* http://domain.com [R,L]
This should work within .htaccess placed in the root directory. The empty rule (nothing between ^$) is interpreted as / (the root). Your subpages and subdirectories should remain unaffected. Requires mod_rewrite.
RewriteEngine on
RewriteRule ^$ http://new.domain.com/ [L]
# subdomain home page to main domain page
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^subdomain\.example\.com$ [NC]
RewriteCond %{REQUEST_URI} ^/?$
RewriteRule .* https://www.example.com [L,R=301]
This works for me as I wanted to have 301 redirect and to https main domain page. I hope this helps. Thanks..
how to redirect example.com to example.com/market using .htaccess file
ex.
http://example.com/details.php?id=3667 and
http://www.example.com/details.php?id=3667
should redirected to
http://example.com/market/details.php?id=3667
and also I want to redirect any example.com to example.com/market
using htaccess
According to here for:
Redirecting www to non-www
RewriteEngine On
RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
Redirect root to subfolder
Redirect / http://example.com/market
Our site have this url
http://mydomain.com/blog.php?id=50
and need redirect its by 301 to
http://blogs.mydomain.com/blog.php?id=50
must create sub domain or folder or can we do it directly .htaccess file ?
Try the following in your .htaccess file
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain\.com [NC]
RewriteCond %{QUERY_STRING} ^id=([0-9]+)$
RewriteRule ^blog\.php$ http://blogs.mydomain.com/blog.php?id=%1 [L,R=301]