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]
Related
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]
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]
We are working on our new site, and we want to make the homepage re-direct to a subdirectory I am wondering how to do this with .htaccess as then any other page they need to go back to the old site.
These rules will forward http://yourdomain.example.com to http://yourdomain.example.com/yoursubdir/
RewriteEngine on
RewriteRule ^/?$ yoursubdir/ [L]
If you want, instead, to redirect an URL with index.php (like http://yourdomain.example.com/index.php use this rules instead.
RewriteEngine on
RewriteRule ^index.php$ yoursubdir/ [L]
In general have a look at the documentation of mod_rewrite. There are many useful and free guides around the net.
Something like this should do the trick
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/some/subdir/$1 [R=301,L]
This will rewrite the requested URI to some/subdir of newdomain.com
I'm quite new about modifying .htaccess and I'm having some problems getting some subfolders to be redirected to the homepage properly.
I wouldn't mind if it was just one domain but I recently bought some aged domains with installed wordpress.
Basically I have this URL: http://hockeyplock.se/c/LTableCalculate.aspx?LId=162
And I want to redirect it to: http://www.hockeyplock.se
So far this is what I have in the .htaccess but it does not do the trick.
RewriteEngine On
RedirectMatch 301 /c/(.*) /
Then I also tried this:
RewriteRule ^c/(.+)$ http://hockeyplock.se/$1 [R=301,L]
But with no success.
I know the two methods are different things. I’m just trying to find out a solution to this asap.
You were almost there:
RewriteEngine on
RewriteBase /
RewriteRule ^c/(.+)$ http://hockeyplock.se/ [R=301,L]
Try putting the followig in your .htaccess file in the root of your hockeyplock domain
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/c/.+$ [NC]
RewriteRule . http://www.hockeyplock.se/? [R=301,L]
I'd like to redirect a website from http:// domain.com & http:// www.domain.com to http://v2.domain.com, while maintaining access to http:// (www.)domain.com/images/*
I've tried several methods but somehow I can no longer access the /images folder anymore.
P.S: both subdomain & root has different content/CMS. Any ideas as to how to implement this?
Thanks
You haven't explained exactly how these are configured. I'm going to assume that www.domain.com and v2.domain.com are different virtual hosts:
You should be able to do this in your .htaccess file or apache configuration for www.domain.com:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !images/
RewriteRule ^/(.*) http://v2.domain.com/$1 [L,R]
I realised something like this could work as well. Probably need some testing, but if this is wrong do comment.
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/images/
RewriteCond %{HTTP_HOST} !v2\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://v2.domain.com/ [R=302,L]