HTACCESS: Do a url rewrite - .htaccess

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]

Related

Redirect this dynamic URL to html URL with htaccess

I have lot or articles with this URL format:
mydomain/art/details.php?articleid=24463&parentid=1&catid=166
the above is an example.
And i want that redirect these kind of URL to :
mydomain/art/24463.html
Please let me know that how can i do it with .htaccess?
Thanks in advance
Instead of mydomain/art/24463.html you should choose something like mydomain/art-166/1-24463.html.
This way, you'll include also parentid and catid which are dynamic parameters (and so, needed for rewriting).
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/art/details\.php\?articleid=(\d+)&parentid=(\d+)&catid=(\d+)\s [NC]
RewriteRule ^ /art-%3/%2-%1.html? [R=301,L]
RewriteRule ^art-(\d+)/(\d+)-(\d+)\.html$ /art/details.php?articleid=$3&parentid=$2&catid=$1 [L]
Try this in htaccess tester
RewriteEngine on
RewriteRule ^art/(\d+).html$ art/details.php?articleid=$1&parentid=1&catid=166 [nc]

htaccess redirect from one url to another url

I am bit stuck one redirecting one url to another url.
I want to redirect
http://samedomain.com/?abc
to
http://samedomain.com/news/title
Any help is highly appreciated. Thanks in advance.
This rewrite rule will redirect http://samedomain.com/?abc to http://samedomain.com/news/title:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^abc$
RewriteRule ^ /news/title/? [L,R=301]

How can I redirect a subdomain to a specific URL?

I am updating the Iirf.ini file to redirect sub.columbia.edu to giving.columbia.edu/video.
sub.columbia.edu is already redirecting to giving.columbia.edu.
How can I go one step further to redirect it to giving.columbia.edu/video.
Important Note: I would like the URL to show as sub.columbia.edu in the browser and not as giving.columbia.edu/video
#Redirect subdomain to specific URL
RewriteCond %{HTTP_HOST} ^sub\.columbia\.edu
RewriteRule ^/$ /video
The above doesn't work. Any ideas how I should modify this?
Thank you!
You can try this and see how it works for you.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub\.columbia\.edu
RewriteRule ^(.*) http://giving.columbia.edu/video [L,R=301]
Or you can do a redirect, this should work also.
Redirect 301 / http://giving.columbia.edu/video

Rewrite Rule in .htaccess: Subdomain to static link

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]

.htaccess mod_rewrite pretty URLs with subdomain

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]

Resources