Link to home
Start Free TrialLog in
Avatar of detox1978
detox1978Flag for United Kingdom of Great Britain and Northern Ireland

asked on

http.conf URL rewrite - remove all FQDN links

Hi All,

I work for a company that doesn't have internet access.  I'd like to use some open source software, but it because it has loads of internet based content embedded - e.g. google fonts.  It takes ages to load.

Would it be possible to change all links to local

e.g.

http://themes.googleusercontent.com/static/fonts/opensans/v6/DXI1ORHCpsQm3Vp6mXoaTXhCUOGz7vYGh680lGh-uXM.woff 

To

/static/fonts/opensans/v6/DXI1ORHCpsQm3Vp6mXoaTXhCUOGz7vYGh680lGh-uXM.woff


Many thanks
D
Avatar of Dr. Klahn
Dr. Klahn

Technically, sure, this can be done.

In real life, it's often impractical.

  • You would have to go through every single page, find out where the internet downloaded "stuff" is, download it as an imaged file, and then store those imaged files locally.
  • Some content is dynamically generated, which means the next time you use it it'll be out of date or it won't work.
  • Some content depends on other content you can't see back at the issuers' sites, such as big databases
  • A lot of content wants to use cookies (either standard or Flash) and that problem is messy to deal with.
Avatar of detox1978

ASKER

There arent that many pages, so only 20ish urls that need switching.

Need help getting it to work.
The question is how to change URL's using http.rewrite, so I don't need to go through each page.

I just need to know the URL's that I'd like to change and http.rewrite will update them before sending the web browser.
Replace "YOURDOMAIN.COM" with your actual domain

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^YOURDOMAIN\.com$ [NC]
RewriteRule ^(.*)$ %{SERVER_PROTOCOL}://YOURDOMAIN.com/%{REQUEST_URI} [R=301,L]

Open in new window

Sorry for the delay in responding.  I've been away with work.

The website URL is http://helpdesk.  I added the code below which is being picked up but doesn't change all the URLs to http://helpdesk

RewriteBase /
RewriteCond %{HTTP_HOST} !^helpdesk$ [NC]
RewriteRule ^(.*)$ %{SERVER_PROTOCOL}://helpdesk/%{REQUEST_URI} [R=301,L]

Open in new window


Any suggestion?
e.g. if the source code links to a javascript file https://www.google-analytics.com/ga.js.  The user would look receive http://helpdesk/ga.js
ah okay... I was also matching the protocol (http/https)

I've modified it for you below:

RewriteBase /
RewriteCond %{HTTP_HOST} !^helpdesk$ [NC]
RewriteRule ^(.*)$ http://helpdesk/%{REQUEST_URI} [R=301,L]
ASKER CERTIFIED SOLUTION
Avatar of Rob
Rob
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial