Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
Thread Tools Display Modes
Share |
  #1  
Old 04-09-2015, 01:15 PM
searchbliss's Avatar
searchbliss searchbliss is offline
v7n Mentor
 
Join Date: 03-25-06
Location: USA
Posts: 1,676
iTrader: 1 / 100%
Htaccess help! J. H. Rasmussen are you there?

I need redirect help for an apache server using the htaccess file. J. H. Rasmussen helped me accomplish this with the web.config on a Windows server as follows:
Code:
<rule name="MobileRedirect" patternSyntax="ECMAScript" stopProcessing="true"> <match url="^(.+)" /> <conditions> <add input="{HTTP_USER_AGENT}" pattern="iPhone|iPod|blackberry|android" /> </conditions> <action type="Redirect" url="http://searchbliss.powered.mobi/?ContentPath=http:%2F%2F{HTTP_HOST}%2F{UrlEncode:{REQUEST_URI}}" appendQueryString="false" redirectType="Found" /> </rule>
I need to accomplish the same thing in an htaccess file. What I have here works, but all get directed to the homepage. Like above, I need the query string with the desktop urls in it.
Code:
RewriteCond %{HTTP_USER_AGENT} ((.*iPhone.*)|(.*iPod.*)|(.*BlackBerry.*)|(.*Android.*Mobile.*)|(.*Windows\ CE.*)|(.*IEMobile.*)|(.*Opera\ Mini.*)|(.*Opera\ Mobi.*)) RewriteCond %{HTTP_COOKIE} !dm_show_classic RewriteCond %{QUERY_STRING} !no_redirect=true [NC] RewriteCond %{HTTP_HOST} ^www\.affordablewebsite\.net [NC] RewriteRule ^(.*)$ http://affordablewebsite.powered.mobi/ [L] RewriteBase /
Please help! Thanks
 
Reply With Quote

Advertisement

Advertisement

  #2  
Old 04-09-2015, 01:59 PM
J. H. Rasmussen J. H. Rasmussen is offline
Super Moderator
 
Join Date: 11-11-11
Location: Copenhagen, Denmark
Posts: 5,998
iTrader: 1 / 100%
Code:
RewriteEngine on RewriteBase / RewriteCond %{HTTP_COOKIE} !^.*dm_show_classic.*$ [NC] RewriteCond %{QUERY_STRING} !^.*no_redirect=true.*$ [NC] RewriteCond %{HTTP_USER_AGENT} ^(iPhone|iPad|BlackBerry) [NC] RewriteCond %{HTTP_HOST} ^www\.affordablewebsite\.net [NC] RewriteRule ^(.*)$ http://affordablewebsite.powered.mobi/?ContentPath=$1 [R=302,L,B]
Maybe try this, i am not near a server supporting .htaccess so i have not been able to test it.
 
Reply With Quote
  #3  
Old 04-09-2015, 02:22 PM
searchbliss's Avatar
searchbliss searchbliss is offline
v7n Mentor
 
Join Date: 03-25-06
Location: USA
Posts: 1,676
iTrader: 1 / 100%
Thanks for your help again. I get a 404 error showing that
Code:
/someDirectory/http://affordablewebsite.powered.mobi/http://affordablewebsite.powered.mobi/http://affordablewebsite.powered.mobi/
and so on does not exist???
 
Reply With Quote
  #4  
Old 04-10-2015, 06:51 AM
searchbliss's Avatar
searchbliss searchbliss is offline
v7n Mentor
 
Join Date: 03-25-06
Location: USA
Posts: 1,676
iTrader: 1 / 100%
J. H.,
I really appreciate your help. No matter what I do, i can't get it to work. Any other ideas?

Thanks,
John
 
Reply With Quote
  #5  
Old 04-10-2015, 12:15 PM
J. H. Rasmussen J. H. Rasmussen is offline
Super Moderator
 
Join Date: 11-11-11
Location: Copenhagen, Denmark
Posts: 5,998
iTrader: 1 / 100%
I have tested this, and it seem to work like you want it to:
Code:
RewriteEngine on RewriteBase / RewriteCond %{HTTP_COOKIE} !^.*dm_show_classic.*$ [NC] RewriteCond %{QUERY_STRING} !^.*no_redirect=true.*$ [NC] RewriteCond %{HTTP_USER_AGENT} (iPhone|iPad|BlackBerry) [NC] RewriteCond %{HTTP_HOST} ^www\.affordablewebsite\.net$ [NC] RewriteRule ^(.*)$ http://affordablewebsite.powered.mobi/?ContentPath=http://%{HTTP_HOST}/$1 [R=302,L]
 
Reply With Quote
  #6  
Old 04-10-2015, 02:41 PM
searchbliss's Avatar
searchbliss searchbliss is offline
v7n Mentor
 
Join Date: 03-25-06
Location: USA
Posts: 1,676
iTrader: 1 / 100%
Perfect, thanks again for all your help!
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
.htaccess help DigitalAlien Coding Forum 7 05-14-2011 02:35 AM
Need help in htaccess. drewgrantt SEO Forum 5 04-01-2011 12:14 AM
.htaccess racercam Coding Forum 22 03-30-2011 06:03 PM
Conflict, What is the right htaccess rule, default homepage file with htaccess? basketmen Coding Forum 2 01-20-2009 08:50 AM
htaccess help kwvarga Coding Forum 8 03-21-2006 05:42 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 01:57 PM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC