I'm setting up a new subdomain on our development server to deploy a copy of our new website.
The copy of the site is set out like this: site.develop.rav.domain.co.uk
Annoyingly all links and resources are generating their links to develop.rav.domain.co.uk
Trying to use htaccess to solve this, as has been previously managed with another subsubsubdomain. Here's what I have but it isnt working
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^develop\.rav\.domain\.co.uk$ [NC]
RewriteRule ^(.*)$ http://site.develop.rav.domain.co.uk/$1 [L,R=301]
Not done much with htaccess before so any help will be appreciated
On closer inspection the URL being written for resources is: ukcl-rav-vdev01\.rav\.contactlaw\.co.uk
Related
I am using the following code within .htaccess file of my domain directory to mask my subdomain as amazon.com webpage. Its showing amazon.com however URL also gets changed amazon.com. I did some research online and seems like I am using the correct code. What I am missing?
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain.domain.in$ [NC]
RewriteRule ^(.*)$ http://www.amazon.com%{REQUEST_URI} [R=301,NC,L,QSA]
I recently updates some software on my site and the urls to reference the database have changed. I need to create a rewrite rule to forward the old database links to their new url. I've tried for quite awhile with no luck and decided that after my last attempt at a rule completely errored out the entire site I would come ask for some help.
The trialing "X" below is a variable.
Old url:
http://www.mysite.com/downloads/index.php?do=listings&catid=X
needs to be forward to new url:
http://www.mysite.com/downloads/index.php?categoryid=X
Thanks.
Try adding this to the htaccess file in your document root:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^do=listing&catid=(.*)$
RewriteRule ^/?downloads/(index\.php)?$ /downloads/index.php?categoryid=%1 [L,R=301]
Or, if you need to put it in the downloads directory:
RewriteEngine On
RewriteBase /downloads/
RewriteCond %{QUERY_STRING} ^do=listing&catid=(.*)$
RewriteRule ^(index\.php)?$ index.php?categoryid=%1 [L,R=301]
I have a website. I created a mirror of it and uploaded it in a directory called 'mirror'. What I wanted to do is whenever a viewer access for example..
http://www.example.com/this-page/another-segment/?id=1
I want him to be redirected to..
http://www.example.com/mirror/this-page/another-segment/?id=1
^^^^^^
(I am doing this because I want to want to edit my site's design but I don't want viewers to see the changes in progress until they are complete. Thus I want to redirect them to the mirrored snapshot, at least temporarily.)
Please suggest how this can be done using .htaccess or not.
after browsing around the internet. i came up with the idea of putting a /$1, a rewritebase and followsymlinks on the answer givien by appclay
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/mirror/
RewriteRule (.*) /mirror/$1 [R=301,L]
You'll want to do something like:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/mirror/
RewriteRule ^/(.*) /mirror/$1 [R]
In your .htaccess file.
I am working on a project in PHP and using Apache server.
Say, my project's url is myurl.com.
When i visit
http://myurl.com
it works well.
But when I visit
http://www.myurl.com OR www.myurl.com
it redirects me to http://myurl.com, dropping the www subdirectory.
I want it to stay same, like if we visit http://www.myurl.com it should keep the "www" in url.
I believe this is a .htaccess setting.
I couldn't get the settings right.
Please guide
Thanks
You should open the htaccess file and search for something like
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.myurl\.com$ [NC]
RewriteRule ^(.*)$ http://www.myurl.com/$1 [R=301,L]
This code is redirecting.
Look further here: http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html#m0-askapache2
I have hosting setup with a master domain (mapped to the web root) and then a number of addon domains (each with their own folder within the web root). At the moment you can visit www.masterdomain.com/addondomainsubdir and reach the same page as you would if you visited www.addondomain.com (which maps to /public_html/addondomainsubdir). I want to prevent this so if you visit www.masterdomain.com/addondomainsubdir then it will do a 301 redirect to www.addondomain.com. The new addondomain.com site is a single page site so it does not have to map any additional pages.
Adding rules to the htaccess file in the web root does notaffect anything as the subdir exists which is wierd as i thought the htaccess command should work even if there is a matching subdir (i've tried the following which works when there's no matching subdir):
RewriteRule ^addondomainsubdir?$ http://www.addondomain.com [NC,R=301,L]
Logically given it's reaching this directory I figure i need to add a command within the htaccess file in the addondomainsubdir directory however nothing appears to have any effect (i've got various other rules setup and they work fine).
I would be massively grateful if anyone explain the best way to rectify this?
Thanks so much for your help,
Dave
I know this is an old post, but it has never been successfully answered. So for all of you finding this via search, this should do what the OP is asking.
Add this line to your .htaccess file:
redirect permanent /addondomainsubdir/ http://www.addondomain.com
Try these rules in your .htaccess:
Options +FollowSymlinks -MultiViews
RewriteEngine on
# for http
RewriteCond %{HTTP_HOST} ^(www\.)?masterdomain\.com$ [NC]
RewriteCond %{SERVER_PORT} =80
RewriteRule ^([^/]+)/?$ http://www.$1.com/ [R=301,L]
# for https
RewriteCond %{HTTP_HOST} ^(www\.)?masterdomain\.com$ [NC]
RewriteCond %{SERVER_PORT} =443
RewriteRule ^([^/]+)/?$ https://www.$1.com/ [R=301,L]
Instead of putting a rule in your main .htaccess, I would make make a .htaccess for each add-on domain, putting each one in the respective subdirectory.
RewriteEngine on
RewriteCond %{HTTP_HOST} masterdomain\.com$ [NC]
RewriteRule ^addondomainsubdir(.*)$ http://www.addondomain.com/$1 [R=301,L]