I want to use CSSs, JSs and images over https on http pages - apache

I want to use CSSs, JSs and images over https on http pages on apache.
How and what sould I configure for use the some link on HTTPS as well as HTTP like...
src='//www.site.com/_js/script.js'
And what is the right directory structure for this kind of use? Right now I'm using this...
/domain.com
/private_html
/js
/images
/css
/public_html
/index.html

On a page with the url of proto://host/some/file.ext, the following link src='/_js/script.js' will be processed by browser as if it was src='proto://host/_js/script.js'.

Related

Strip HTML extension from outgoing URL

I am using AEM. I have configured some vanity URL's with redirect. Ex:
/coaties > /content/geometrixx-outdoors/women/coats/winter-coat.html
Also in the web server, I have made configuration to strip HTML extension so my web-server removes the html extension with another redirect. Now when I hit vanity URL, I will have 2 redirects
/coaties > /content/geometrixx-outdoors/women/coats/winter-coat.html [1st redirect]
/content/geometrixx-outdoors/women/coats/winter-coat.html >
/content/geometrixx-outdoors/women/coats/winter-coat [2nd redirect]
I want to avoid 2 redirects and I dont want to show HTML extension to end users.
/coaties > /content/geometrixx-outdoors/women/coats/winter-coat [only one redirect]
I spent some time on the Sling side with no luck. All I understand is, since Sling will return 403 for all URL's without extension, it always returns URLs with extension. Is this possible at dispatcher or web server side ?
If i understand, you want to strip the .html extension from all the pages of your site.
The solution of #awd will ensure that all the hrefs in your page would be transformed to uris with no extension.
If you want no extension at all in your site, you should use an internal redirect by creating map under /etc/maps, you can find the official documentation here: http://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html
Thanks everyone for contributing.
I found the following solution for the problem
I would do the following configurations for webserver
For apache, in httpd.conf
Header edit Location (.*).html$ $1
For iPlanet in obj.conf
<If $srvhdrs{'Location'} =~ "^(.*).html$">
Output fn="set-variable" $srvhdrs{'Location'}="$1"
</If>
This would make sure that html extension would be removed from location header for redirected URL's.

Apache Redirect domain.com/dir/slug to sub.domain.com/dir/slug silently without .htaccess

I'm having the darndest time trying to figure this out.
I have a site on a legacy system which will not permit me to alter the .htaccess file at domain.com. I have moved part of this site to a WordPress install located at sub.domain.com. I have to make the URL domain.com/dir/ redirect silently to sub.domain.com/dir/. How can I go about this? I can edit the Apache config files for both domain.com and sub.domain.com, and the .htaccess for sub.domain.com, but not the .htaccess for domain.com
Thanks!
Just add the redirect into the apache config files. In the virtualhost for domain.com:
Redirect 301 / http://sub.domain.com/
If by "silently" (not sure what that's supposed to mean since redirects are involve the browser sending a new request), I'm guessing you want to reverse proxy? Then you'd need to make sure mod_proxy is loaded, then do:
ProxyPass / http://sub.domain.com/

Apache: How can i redirect all sites on the server to an URL?

I have a VPS based Centos/cPanel-WHM. I wanna redirect all sites (including all pages & subdomains) on the server to one URL. How can i do this?
create .htaccess file in every website DocumentRoot dir which you want to redirect
# This allows you to redirect your entire website to any other domain
Redirect 301 / http://exampledomain-redirect.com/
At webserver layer (change the .htaccess), you could issue 301 redirects for any requests to your sites to new URL
OR
you could inject javascript (through your web layer) or your code layout framework OR manually
at the head of the page to complete a redirect.
OR
if your domains point to different hosting.. you could upate their NS to point to your new location and do 1 OR 2
.htaccess is the best way, Otherwise change the document root for each site.

How to force apache only to serve a single file?

My site uses nginx. I use apache only for large file uploading to the server. I have a script upload.php which I POST the files to via a flash uploader script.
Apache runs on a subdomain, so I post files to upload.domain.com/upload.php
Is there any way to prevent apache from serving the actual site on that subdomain? ideally I want to post files to upload.subdomain.com and have it be directed to upload.php on that subdomain
I mean I could setup a different document root for apache and thats it, but are there any other ways?
If I understand correctly you want all requests to upload.domain.com to be directed to upload.php? A RewriteRule inside the VirtualHost that catches all requests should work:
RewriteEngine On
RewriteRule . /full/path/to/upload.php

HTML Base Equivalent in .htaccess?

Let's say you have the following setup.
You have a server with the basepath set to the normal webroot.
The server has files in the following structure
/projects
/some-unique-id
/index.html
/images
/some-unique-id
/index.html
/images
Is it possible to have a .htaccess file somehow redirect the paths so if index.html has absolute paths they work.
For example if index.html contains /images/foo.gif can this magically become /projects/some-unique-id/images/foo.gif
The equivalent of the base html tag.
This is part of a CMS deliverable previewing system so I am restricted to not changing the HTML code.
Is there anyway to address this in an .htaccess file?
If each index.html contains <img src="/images/foo.gif"/>, the browser will request that URL and there will be no way for the server to know which page caused the request since the requests will be identical regardless of the originating page.
There is no way to do this with mod_rewrite unless you try to check the Referer header, which would be unreliable at best.
You will have to change your HTML markup to solve this. Using relative URLs seems like it would solve your problem.