I want to do this:
sub.domain.com/
show content of:
domain.com/test/
I config htaccess file like this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^sub.domain.com
RewriteRule ^(.*)$ http://domain.com/test/$1 [L,NC,QSA]
But It's not working. The url : sub.domain.com still display content of domain.com
Try using an absolute path insted of using full url
RewriteEngine on
RewriteCond %{HTTP_HOST} ^sub.domain.com
RewriteRule ^(.*)$ /test/$1 [L,NC,QSA]
Related
How I can redirect using .htaccess file from domain: testÓwka.net to domain testOwka.net with saving URL path?
For example, when user visit website: testówka.net/login, I want to redirect this user to: testowka.net/login.
I tried in that way:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^testówka\.net$ [NC]
RewriteRule ^ http://ofertowka.net%{REQUEST_URI} [L,R]
and in that way:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^xn\-\-testwka\-o0a\.net$ [NC]
RewriteRule ^ http://testowka.net%{REQUEST_URI} [L,R]
I tried with escape and without but nothing work fine. How I can do it?
Try modify your rewrite to:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?xn--testwka-o0a\.net [NC]
RewriteRule (.*) http://testowka.net/$1 [R=301,L]
I already added a subdomain wildcard to my dns (*.domain.com) but now i can't get the rule right.
I want
subdomain.domain.com
to point to
domain.com/subdomain
my htaccess file is :
RewriteEngine On
RewriteCond %{HTTP_OST} ^(?:www\.)?((?!www\.)[^.]+)\.(domain\.com)$ [NC]
RewriteRule ^/?$ http://www.%2/%1 [R=302,L]
but i'm getting Internal Server Error.
How can i get it to work ?
If you want it to actually redirect then you can do this
RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/subdomain/$1 [R=301,L]
If you don't want it to redirect and keep subdomain.example.com in the address bar then, you can do this.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain\.example\.com [NC]
RewriteRule ^(.*)$ /subdomain/$1 [L]
I am pointing blog.website.com at website.com/blog correctly however I want the URL to remain as blog.website.com
Here is my .htaccess file
RewriteEngine on
RewriteCond %{HTTP_HOST} ^blog\.website\.com$
RewriteRule ^/?$ "http\:\/\/website\.com\/blog" [L]
How can I do this?
UPDATE
I have managed to do it using the following code in my .htaccess file:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^blog\.website\.com$
RewriteCond %{REQUEST_URI} !^/blog/$
RewriteRule (.*) http://website.com/blog/ [P]
However, now my blog images are not showing. If I put them into the blog folder created for the subdomain, they work, but I want to keep them inside the website.com/blog folder, how can I achieve this?
Try this rule instead:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^blog\.website\.com$
RewriteRule !^blog/ blog%{REQUEST_URI} [L]
I'm looking for a way to do something like this in .htaccess:
This.is.my-website.com
Please note: This.is is the rewrite to the directory This.is and mywebsite.com is the URL of the site. I want all requests to the site to be redirected to that folder (301?). Is it possible to achieve this in .htaccess?
Try:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.+)\.my-website.com$ [NC]
RewriteRule ^(.*)$ /%1/$1 [L]
for an internal rewrite (won't change the URL in browser's address bar).
Or to externally redirect:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.+)\.my-website.com$ [NC]
RewriteRule ^(.*)$ http://my-website.com/%1/$1 [L,R=301]
I have .htaccess file:
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^somedomain.com [NC]
RewriteRule ^(.*)$ http://www.somedomain.com/$1 [R=301,NC]
RewriteRule ^r/(.*)$ index.php?rid=$1 [NC]
But last condition performs redirect in browser when I request URL like www.somedomain.com/r/123 and show me URL like www.somedomain.com/index.php?rid=123. But I need call this script without URL change.
What's wrong?
You used the R=301 Try to use L just like following:
RewriteCond %{HTTP_HOST} ^somedomain.com [L]
RewriteRule ^(.*)$ http://www.somedomain.com/$1 [L]
RewriteRule ^r/(.*)$ index.php?rid=$1 [L]