I want to rewrite from
subdomain.domain.com
to an static link like
www.domain.com/pageId5.
The Domains are the same, i tried a lot of things in .htaccess but nothing works. I also found nothing helpfull with the search function, please help!
And Iam working with Drupal, so there are no directories I can point to.
Try putting this in the htaccess file in your document root:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain.domain.com$ [NC]
RewriteRule ^$ http://www.domain.com/pageId5 [R=301,L]
Related
I have multiple domains and one htaccess for these. We split off some content from domain1.com to domain2.com and I need to redirect to the new page.
Redirect 301 /folder/page.html https://www.domain2.com/folder/page.html
resulted in a infinity loop ... i also tried this but its dont work:
RewriteCond %{HTTP_HOST} ^domain1.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain1.com$
RewriteRule ^/folder/page.html https://www.domain2.com/folder/page.html [R=301,L]
I also need to mention that not all pages from domain1 should redirect to domain2 but it would be ok if the whole folder is redirected
my knowledge of htaccess isnt that big hope you can help me!
Based on your shown samples, could you please try following. Please place this to the top of your htaccess file.
Also please make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.com$ [NC]
RewriteRule ^folder/page\.html https://www.domain2.com/folder/page.html [R=301,NC,L]
I'm trying to use htaccess to do a url rewrite.
I would like the people to access the site in the browser using this:
http://exmaple.com/ladada
But the files are inside a subdomain:
http://ladada.exmaple.com
Would that be possible? People will access the site using the first link but in the backend it's being rewritten to the second link? Thank you so much!
mod_rewrite doc should help you.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^ladada\.example\.com [NC]
RewriteRule (.*) http://example.com/ladada/$1 [L,R=301]
Have site with many languages
extra languages are in subdomains on my server like de.mydomain.com, fr.mydomain.com.
in these de,fr subdirectory i've placed only htaccess file with this code:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.de\.mydomain\.com$
RewriteRule ^(.*)$ "http://www.mydomain.com/$1?lan=2%1" [L]
And it works but not how I want. it simply redirects from de.mydomain.com to mydomain.com, url in the browser is changing and I would like the url to stay like: de.mydomain.com but the content to be taken from mydomain.com?lan=2.(i use lan variable to change lang)
what do I do wrong here?
maybe my general aproach to this problem is wrong?
Edit :
You need to point de subdomain to the root directory instead, and then adding these lines to the root htaccess file :
RewriteCond %{HTTP_HOST} ^(www\.)?de\.mydomain\.com$
RewriteRule ^(.*)$ /$1?lan=2 [L,QSA]
Put this rule before your rule:
RewriteRule !^(fr|en)/ /en%{REQUEST_URI} [L,R=301]
.htaccess rewrite to default language folder?
I'm not even sure if this is possible but have been looking everywhere for a solution. My site generates dynamic info about domain names and people can view their info in the following format:
http://www.mysite.com/analyze/yourdomain.com
The problem is that sometimes people will enter http:// or www or even the full URL instead of their domain, such as this:
http://www.mysite.com/analyze/http://www.yourdomain.com/this-is-a-test
What I'd like to do with htaccess is get the domain name and redirect it to the proper URL like the first one listed.
This is what I currently have for my htaccess:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite.com$
RewriteCond %{REQUEST_URI} !\.(xml|txt)$
RewriteRule ^(.*)$ http://www.mysite.com/review/$1 [R=301,L]
Options -MultiViews +FollowSymlinks -Indexes
RewriteEngine on
RewriteCond %{REQUEST_URI} !\.(xml|txt)$
RewriteRule ^([a-zA-Z0-9\.\-]+)$ review.php?site=$1 [L,QSA]
The main issue that I'm having is that every tutorial I find about stripping/redirecting domains is applying to my actual domain name, not the user's in the URL. Any help would be greatly appreciated!
Try adding thie right below your first rule (that 301 redirects):
RewriteRule ^analyze/http:/+([^/]+)/? /analyze/$1 [L,R=301]
This will redirect requests like http://www.mysite.com/analyze/http://www.yourdomain.com/this-is-a-test to http://www.mysite.com/analyze/yourdomain.com.
I'm trying to get my URLs from this:
hxxp://m.newsite.com/index.php?id=12345
To this:
hxxp://m.newsite.com/12345
The trouble I have is I have a shared hosting account and I'm hosting a new domain, so the above URL w/subdomain is technically accessible from:
hxxp://www.originalsite.com/newsite.com/mobile
I've tried a variety of different combinations for mod_rewrite, but I'm afraid I'm just not there! Help!
Put this in the htaccess in the /newsite.com/mobile directorie
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^m\.newsite\.com$
RewriteRule ^([0-9]+)$ index.php?id=$1 [L]