Accessing parent site folder from mobile site after htaccess redirect
I am redirecting my site to a mobile site when accessed via a mobile device.
Here's the htaccess code:
RewriteCond %{QUERY_STRING} !^desktop
RewriteCond %{HTTP_USER_AGENT} android|avantgo|blackberry|iphone [NC]
RewriteRule ^ http://m.example.com%{REQUEST_URI} [R,L]
The FTP folder structure is as follows:
Images
ProImages
Mobile // All mobile site data into this
When I try to access http://www.example.com/ProImages/abc.jpg
from my mobile site it doesn't show up because as soon as it tries to call www
it redirects to m
.
I tried using ../ProImages
it but it still didn't solve the problem.
Can anyone help with this?
source to share
You can make a symbolic link to your images folder from your Mobile folder.
If you have shell access, inside the Mobile folder, run:
ln -s /path/to/document/root/ProImages ./ProImages
This way you can call Mobile/ProImages
and the displayed content is ProImages
from the parent folder.
source to share
I usually redirect everything using a server, but for mobile using PHP. I recommend using the mobile_detect class. I work greatand it fits pretty much everything. You can even discover based on specific features like tablet or ipad or whatever. It is very easy to use and doesn't make a user agent with .htaccess. So you can do an if statement like below and then do a redirect with php.
Here are some code examples for their page. http://mobiledetect.net/
// Include and instantiate the class.
require_once 'Mobile_Detect.php';
$detect = new Mobile_Detect;
// Any mobile device (phones or tablets).
if ( $detect->isMobile() ) {
header('Location: http://m.example.com/'.$_SERVER["REQUEST_URI"]);
}
// Any tablet device.
if( $detect->isTablet() ){
}
// Exclude tablets.
if( $detect->isMobile() && !$detect->isTablet() ){
}
// Check for a specific platform with the help of the magic methods:
if( $detect->isiOS() ){
}
if( $detect->isAndroidOS() ){
}
// Alternative method is() for checking specific properties.
// WARNING: this method is in BETA, some keyword properties will change in the future.
$detect->is('Chrome')
$detect->is('iOS')
$detect->is('UC Browser')
// [...]
// Batch mode using setUserAgent():
$userAgents = array(
'Mozilla/5.0 (Linux; Android 4.0.4; Desire HD Build/IMM76D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19',
'BlackBerry7100i/4.1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/103',
// [...]
);
foreach($userAgents as $userAgent){
$detect->setUserAgent($userAgent);
$isMobile = $detect->isMobile();
$isTablet = $detect->isTablet();
// Use the force however you want.
}
// Get the version() of components.
// WARNING: this method is in BETA, some keyword properties will change in the future.
$detect->version('iPad'); // 4.3 (float)
$detect->version('iPhone') // 3.1 (float)
$detect->version('Android'); // 2.1 (float)
$detect->version('Opera Mini'); // 5.0 (float)
// [...]
source to share