How to use m.domain.com with htaccess - .htaccess

How can I make www.domain.com/mobile.html show up as m.domain.com in the browser bar?
My standard index.html file is in the root directory, so its adress is www.domain.com/index.html.
It uses javascript to redirect users to a mobile website at www.domain.com/mobile.html.
I just want it to show up differently in the adress bar, not change the actual location of the mobile.html file.

I could not get this to work properly with an .htaccess file on my web server. Instead I used the folowing workaround instead:
the html index file at www.domain.com redirects mobile users to m.domain.com on detection of a screen.width <= 1024px.
<script type="text/javascript">
if (screen.width <= 1024) {
document.location = "http://m.spotlightfoto.nl";
}
</script>
Only the mobile version of the index is located at m.domain.com and is linked to all it's resources at the www.domain.com by adding a <base href> at the very top of the <head>
<base href="http://www.domain.com">
I'm posting this for future reference.
Maybe it's not the most efficient or lean way of doing this, but it does give the desired results. The downside would be the added request by first going to the regular index.html before redirecting the mobile user to the mobile domain.

Related

Disable desktop user-agents

I've got a website currently running.
I would like for ONLY mobile users to be able to use the website.
So anyone who is on a desktop, it will show a 404 error or such.
How can I go about doing this?
Would user-agents be the proper way to go about doing this?
Thanks,
Yes detect the uger agents and redirect to an error page or welcome page from a filter on your server.
I did this using screen size:
<script type="text/javascript">
<!--
if (screen.width => 699) {
document.location = "Yoursite/404";
}
</script>

How to run content script code on an HTML file locally hosted by Google Chrome Extension? [duplicate]

I want to run a content script on an iframe with a chrome-extension:// URL. I added a line to my manifest.json that I copied out of the documentation http://code.google.com/chrome/extensions/match_patterns.html
chrome-extension://*/*
But when I reload my extension I get an alert:
Could not load extension from '/work/sirius/extension'.
Invalid value for 'content_scripts[2].matches[0]': Invalid scheme.
Any idea how to get this to worK?
No. Only ftp:, file:, http: and https: can be matched by a content script declaration.
Invalid URL patterns at any of the matches and exclude_matches fields are rejected (generating an error when trying to load the extension).
Invalid patterns at the permissions option in the manifest file are ignored.
If you want to run a script on a tab from your extension, use chrome.extension.getViews in your background script.
Even better, design your extension's pages such that they effectively communicate with each other (example).
I'm having the exact same problem, look at the API http://code.google.com/chrome/extensions/match_patterns.html it says clearly that they accept chrome-extension://*/* yet they don't.
They need to update the API so as not to confuse people.
It seems that Chrome authors have silently removed the ability for content scripts to be injected into chrome-extension: pages. Documentation still says that it works and even contains examples with chrome-extension: scheme but actually it doesn't work. So now only http:, https: and ftp: work "from the box" and file: can work if user of your extension has enabled this on Extensions (chrome://extensions/) page.
Update: now documentation referred above is updated and says nothing about ability to inject content scripts to chrome-extension: pages.
You can inject js to your iframe html(chrome-extension: pages) without declaring it in manifast.json. The injected js can visit Chrome APIs directly.
iframe.html:
<!DOCTYPE html>
<html>
<head>
...
</head>
<body>
...
</body>
<script src="iframe.js"></script>
</html>
iframe.js:
console.log(chrome); // {loadTimes: ƒ, csi: ƒ, …}

Add a static frontpage to Meteor.js

I've started learning Meteor.js and it seems fabulous for single page app. But I only know how to create one page for the entire site.
How can I add a static page to http://domain.com and have my Meteor app run at http://domain.com/app? For your solution, will your page actually change when you go to domain.com/app from domain.com?
Check out meteor-router. It lets you assign routes to templates.
If you dont mind calling a html file you can have static pages in /public. This probably wont work for you, because your page probably isnt actually a "static" page. This would be accessed at http://mydomain.com/index.html .
eg,
/public/index.html :
<html>
<head>
<link href="/public/index.css rel="stylesheet">
</head>
<body>
<h1 class="something"> I am a web page </h1>
</body>
</html>

set directory root

I have a subdirectory for a website:
www.example.com/admin
I'm using includes throughout the site that all use the same path structure:
<link rel="stylesheet" href="assets/css/styles.css">
The stylesheets also have links in them for things like background images.
My problem is that the includes don't work in the /admin directory because they all refer to /assets/css or whatever folder that are all up one level. (Those links work fine for the main website in the root directory, but no good for the admin area.)
Anyone got any ideas how to solve this problem?
You need to either add a / to your link (making it an absolute URI instead of the relative URI that it is):
<link rel="stylesheet" href="/assets/css/styles.css">
Or you can add a URI base in your page headers:
<base href="/">

Does content_scripts matches "chrome-extension://*/*" work?

I want to run a content script on an iframe with a chrome-extension:// URL. I added a line to my manifest.json that I copied out of the documentation http://code.google.com/chrome/extensions/match_patterns.html
chrome-extension://*/*
But when I reload my extension I get an alert:
Could not load extension from '/work/sirius/extension'.
Invalid value for 'content_scripts[2].matches[0]': Invalid scheme.
Any idea how to get this to worK?
No. Only ftp:, file:, http: and https: can be matched by a content script declaration.
Invalid URL patterns at any of the matches and exclude_matches fields are rejected (generating an error when trying to load the extension).
Invalid patterns at the permissions option in the manifest file are ignored.
If you want to run a script on a tab from your extension, use chrome.extension.getViews in your background script.
Even better, design your extension's pages such that they effectively communicate with each other (example).
I'm having the exact same problem, look at the API http://code.google.com/chrome/extensions/match_patterns.html it says clearly that they accept chrome-extension://*/* yet they don't.
They need to update the API so as not to confuse people.
It seems that Chrome authors have silently removed the ability for content scripts to be injected into chrome-extension: pages. Documentation still says that it works and even contains examples with chrome-extension: scheme but actually it doesn't work. So now only http:, https: and ftp: work "from the box" and file: can work if user of your extension has enabled this on Extensions (chrome://extensions/) page.
Update: now documentation referred above is updated and says nothing about ability to inject content scripts to chrome-extension: pages.
You can inject js to your iframe html(chrome-extension: pages) without declaring it in manifast.json. The injected js can visit Chrome APIs directly.
iframe.html:
<!DOCTYPE html>
<html>
<head>
...
</head>
<body>
...
</body>
<script src="iframe.js"></script>
</html>
iframe.js:
console.log(chrome); // {loadTimes: ƒ, csi: ƒ, …}

Resources