If your site lives at www.oxwallsample.com, you’re going to want to set up a subdomain at m.oxwallsample.com. How you accomplish this is usually pretty straightforward but differs depending on your host. I use control panel to do the same, I can add subdomains effortlessly until I
pass out from excitement. You want to set up your subdomain as a
“mirror” of your main site, meaning the subdomain is really just
pointing to your existing site.
Step 2: Create global_prepend file
The next thing we’re
going to do is a create a PHP file which will be automatically prepended
to every page of our site. Call this file something like "global_prepend.php" and throw it at the root of your server:
"codes for this file are as below"
<br />
<?php<br />
function callback($buffer) {<br />
if ($_SERVER['SERVER_NAME'] == 'm.oxwallsample.com') {<br />
$buffer = str_replace('http://www.oxwallsample.com', 'http://m.oxwallsample.com', $buffer);<br />
$buffer = preg_replace('/[\n\r\t]+/', '', $buffer);<br />
$buffer = preg_replace('/\s{2,}/', ' ', $buffer);<br />
$buffer = preg_replace('/(<a[^>]*>)(<img[^>]+alt=")([^"]*)("[^>]*>)(<\/a>)/i', '$1$3$5<br />', $buffer);<br />
$buffer = preg_replace('/(<link[^>]+rel="[^"]*stylesheet"[^>]*>|<img[^>]*>|style="[^"]*")|<script[^>]*>.*?<\/script>|<style[^>]*>.*?<\/style>|<!--.*?-->/i', '', $buffer);<br />
$buffer = preg_replace('/<\/head>/i', '<meta name="robots" content="noindex, nofollow"></head>', $buffer);<br />
}<br />
return $buffer;<br />
}<br />
ob_start("callback");<br />
?>
This code uses a PHP function called ob_start() to read in your entire HTML source, run some rules on it, and then send the output to users’ web browsers… all in real time. The first "if" statement simply checks to see if the user is coming from our special “mobile” URL, and if so, runs seven replace statements on the code. Here’s what each line does:
Next, we need to create a tiny PHP file which will automatically get added to the end of every file on our site. This is the code that actually outputs the page to the browser. So the flow is like so: Suck code into buffer, siphon fat away, spit contents of buffer into browser.
The code for the global_append file is below. Call it something like "global_append.php" and throw it at the root of your server:
"codes for this file are as below"
If you don’t already have an .htaccess file at the root of your server, open up a new text file and add these lines to it:
php_value auto_prepend_file /localfilepath/global_prepend.php
php_value auto_append_file /localfilepath/global_append.php
Then save it to the root of your server with the filename ".htaccess". If you already have an .htaccess file, just add the above lines to it.
* Important Note: If you copy these two lines from your web browser, you might need to delete the carriage return and make your own. Sometimes a browser’s carriage return will cause your .htaccess file to fail (you’ll know immediately if it has failed because your site won’t come up).
Assuming your subdomain is live, you should now be able to hit your site in a web browser using the special mobile URL and see a nice, compact, imageless, styleless, scriptless version of your site.Most of the modern mobile browsers display Oxwall sites properly. And of course our team will develop a mobile edition soon because it is really important for a modern Internet users.