Cookieless Domain Help - .htaccess

I've been reading a bit about serving my images, javascript and css from a seperate domain.
I have set up a domain, not a sub domain but a new account on my server.
My site is for example: http://www.site.com
I have set up a new account for http://s1.site.com
To cut it short, I have about 40gb of images, so rather me moving it (would also require me to update a few of my scripts as I have scrapers to grab images) I was wondering if there was a way to point my new sub-domain to my other content?
Basically, I want to create a .htaccess file on s1.site.com and get it to pull the info from www.site.com, for example:
http://www.site.com/images/picture.jpg
becomes
http://s1.site.com/images/picture.jpg
But the image doesn't really exist on the s1.site.com, we are just 'mirroring' it using htaccess to save the hassle of copying everything over to the static domain.
Please let me know how this is possible, as it would save me a great deal of time and would work wonders.
I basically just want to make anything on
http://s1.site.com/* pull from /home/originalsite/public_html/(images/js/css folders)

Related

Only internally re-directing old website to new website within the new website's .htacess file only. How do I do this?

Old website: luffyforums.com/
New website: captainluffy.net/
Lets say I don't have access to my old website. Hence, I can't change the htaccess file from my old website.
I want all links within my new website, which lead to old website to automatically get re-direct to my new website.
It's a vbulletin website.
Example:
A user has posted the following link:
1) http://luffyforums.com/showgroups.php
2) luffyforums.com/faq.php
I want it to be changed to:
1) http://www.captainluffy.net/showgroups.php
2) captainluffy.net/faq.php
if anybody clicks it.
Basically, I'm looking for a coding which makes the new website re-direct all links associated with "luffyforums.com" to "captainluffy.net" without having to access the old domain server.
Preferably a coding which I only have to add to my new website's .htaccess file.
Help would be greatly appreciated :)
You're screwed. When someone goes to http://luffyforums.com/ the browser sends a request right to luffyforums.com, and it isn't even aware that such a place called www.captainluffy.net even exists. The request will be handled by your old website and that's it.
Since your new website (htaccess, the server, the code, everything) isn't even remotely part of this equation, you can't do any redirect from your old website unless you have control over it.
If you were able to do such a thing, people would be redirecting links from banks or ebay or paypal to their private phishing sites to scam people.

Updating an existing website

I've been asked by a family friend to completely overhaul the website for their business. I've designed my own website, so I know some of the basics of web design and development.
To work on their website from my own home, I know I'll need to FTP into their server, and therefore I'll need their FTP credentials, as well as their CMS credentials. I'm meeting with them in a couple of days and I don't want to look like a moron! Is there anything else I need to ask them for during our first meeting (aside from what they want in their new site, etc.) before I start digging into it?
Thanks!
From an SEO point of view, you should be concerned with 301 redirects as (i suppose) some or all URL adressess will change (take a different name, be removed and etc)
So, after you`ve created a new version of the site - and before you put it online - you should go ahead and list all "old site" URLs and decide, preferably for each one, it's new status (unchanged or redirected and if so - to what URL).
Mind that even is the some content will not re-appear on the new site, you still have to redirect the URL (say to HomePage) to keep link juice and SERP rankings.
Also, for a larger sites, (especially dynamic sites) try looking for URL patterns for bulk redirects. For example, if you see that google indexes 1,000 index.php?search=[some-key-word] pages, you don`t need to redirect each one individually as these are probably just search result pages that can be grouped with REGEX to be redirected to main search result page.
To index "old site" URLs you should:
a. site:domainname.com in Google (then set the SERP to 100 results and scaped manually of with Xpath)
b. Xenu or other site crawler (some like screamingfrog) to get a list of all URLs.
c. combine the lists in excel and remove all duplicates.
If you need help with 301 redirects you can start with this link:
http://www.webconfs.com/how-to-redirect-a-webpage.php/
If the website is static, knowing html, css and javascript along with FTP credentials is enough for you to get started. However if the site is dynamic interactive and database driven, you may need to ask if they want to use a php, In that case you might end up building this site in wordpress.
If you are going to design the website from scratch then also keep this point in mind.. Your friend might have hosted this website at somewhere (i.e. hosting provider). You should get its hosting control panel details as well which will help to manage the website (including database, email, FTP, etc.).

PHP - Switching between websites?

A friend of mine set up a website with a website builder. I offered to help and ended up redesigning the site. What I wrote is obviously incompatible with the site builder's templates he used, but he would rather stick with the site builder which allows him to make the changes he needs to make.
What I'm currently thinking is to have both sites set up simultaneously and let him choose which one is visited by the user. That way we can use the new site and then when he makes a change, switch back to the old site until I have a chance to change the new version. This would be confusing for any regular users of the site who happened to visit it in the time that the old site was changed, but the site is very small with very few visitors, and any changes made would be easy to duplicate.
I don't, however, know how to do this. My first thought was to have two public_html directories with a script that would rename them as needed, but I don't know how I would go about changing the name of a folder that a script is running from. I also don't think I would be able to move the old site over to a host I control; the site builder doesn't give the ftp details and it takes care of all the dirty work for its users. At most, I think I could transfer the domain name to a different registrar, set up the nameservers with the host of the new site, and go from there, but then the old site wouldn't be editable from the site builder...
My second thought would be to do something like this in php:
if(...){
echo file_get_contents(oldsite . $_SERVER['REQUEST_URI']);
}
else{
...
}
If anyone's made it this far, here are the key points of what I want to achieve:
Old site is able to be changed with the site builder (vistaprint)
Script to choose which website the user visits
Urls never change
Assume the only control we have over the old site is a simple WYSIWYG editor from the site builder and the ability to change the domain as well as release the domain (for $20, the crooks). Nothing to do with nameservers, ftp, file managers, etc.
Current plan of action: Transfer the domain (lets assume it's http://example.com) to a register and webhost I control. Set up an add-on domain (http://old.example.com) and register the web builder with the addon domain. I'll then have each page set up the way I showed in the second plan:
if(...){
echo file_get_contents('http://old.example.com' . $_SERVER['REQUEST_URI']);
}
else{
...
}
I'm a bit reluctant to do this for a number of reasons, so I was hoping someone could enlighten me on a better method.
You're overthinking this. Just redirect (HTTP status 3xx) to your old site when necessary.

codeigniter controlled access to a url/folder

I am stuck at the situation where I want the url, which contains a folder having some files (html, swf etc.), to be accessible after I validate the user.
For example.
The url to access is:
A - http://mysite.com/files/version/1/file.swf
And this above url is accessible from the link,
B - http://mysite.com/view/1
I have implemented a way to hide the URL A from a normal user but if the user somehow is a semi-techie person then he can know the swf file location from firebug or other tools. So, to make the access-to-file secure what should I do?
If a user somehow knows the first url(A) and then enters it in browser, i have to check if the user is logged-in and if validation is done it lets the url A to be loaded.
Since, in CI, the controller names cannot be named same as the folders in the root directory, in this case i cannot have a controller called “files”. So, the only option left to make this secure access to url work is to use htaccess rule/cond. If this is the only option, then how can it be achieved by htaccess and if not, then what other options do i have.
Will the codeigniter's URI Routes work because when i tried like this:
$route[‘files/version/1/(:any)’] = “view/$1”;
and it doesnt work, maybe because there is no controller/function/param as files/versions/1 ...
looking for quick help. Thanks
There isn't a sure-fire way to do it without, for example, using .htpasswd.
One thing you could implement is sort of "Security by Obscurity". In that case you could redirect all requests to a file to the URL http://mysite.com/view/file-id and then instead of loading the requested file directly, you would load a .php template with the appropriate headers - be it an image, a flash file or anything else.
But it really depends on how the files are going to be managed, since every file will need an entry in the database and you would have to output different headers for different types of files. And if someone still manages to guess the path to the file, it will be directly accessible.

Custom URL in Codeigniter using htaccess

I am developing a site on Codeigniter 2.0.2 . Its a site where companies/users can signup and create their own profile page, have their own custom url(like http://facebook.com/demouser), have their own feedback system, display their services.
This said, I have been successful in display the profile page in the following format
http://mainwebsite.com/company/profile/samplecompany
This displays the home page for the company samplecompany , where company is the controller and profile is the method.
Now I have few questions,
I guess it is possible to create to have/get http://mainwebsite.com/samplecompany using htaccess and a default controller. If anybody can help with the htaccess rule , that would be awesome. I am already using htacess to remove index.php from CI but could not get this working.
There will be few other pages for the given user/company such as feedback, contact us, services etc. So the implementation links that come to my mind is of the form
`
http://mainwebsite.com/company/profile/samplecompany/feedback or
http://mainwebsite.com/samplecompany/feedback
http://mainwebsite.com/company/profile/samplecompany/services or
http://mainwebsite.com/samplecompany/services
http://mainwebsite.com/company/profile/samplecompany/contactus or
http://mainwebsite.com/samplecompany/contactus
wheresamplecompany` is the dynamic part
Is it possible to create site links in the format?
I understand using A record for a given domain, I can point a domain say, http://www.samplecompany.com to http://mainwebsite.com/company/profile/samplecompany so typing http://www.samplecompany.com he should be taken to http://mainwebsite.com/company/profile/samplecompany . If this is successfully implemented, will
http://www.samplecompany.com/feedback
http://www.samplecompany.com/services
http://www.samplecompany.com/contactus
work correctly?
I guess it is possible to create to have/get http://mainwebsite.com/samplecompany using htaccess and a default controller. If anybody can help with the htaccess rule , that would be awesome. I am already using htacess to remove index.php from CI but could not get this working.
There will be few other pages for the given user/company such as feedback, contact us, services etc. So the implementation links that come to my mind is of the form ` http://mainwebsite.com/company/profile/samplecompany/feedback or http://mainwebsite.com/samplecompany/feedback
You can accomplish this using routes. For example, in your /config/routes.php file, put this:
$route['samplecompany'] = "company/profile/samplecompany";
$route['samplecompany/(:any)'] = "company/profiles/samplecompany/$1";
The first rule tells CodeIgniter that when someone accesses http://mainwebsite.com/samplecompany that it should process it as if the URL were "company/profile/samplecompany". The second rule captures anything that comes in the URI string after "samplecompany" and appends it onto the end.
However, if you have multiple companies(not just samplecompany), you're probably going to want to extend CI's router to suppor this unless you want to manually edit the config file each time a new company is added.
OK, you're definitely going to want to handle dynamic company names(as per your comment). This is a little trickier. I can't give you the full code, but I can point you in the right direction.
You'll want to extend CI's router and on an incoming request query the DB for the list of company names. If the URI segment matches a company name, you'll want to serve it up using your company/profile method. If it does not, you will ignore it and let CI handle it normally. Check out this post on this topic for more information: forum link.
Here's a great guide on how to achieve what you need: Codeigniter Vanity URL's.

Resources