473,394 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

htaccess redirect except 1 page

133 100+
Hi,

I am using the following code to redirect my site to a mobile site:

Expand|Select|Wrap|Line Numbers
  1. #redirect mobile browsers
  2. RewriteCond %{HTTP_USER_AGENT} ^.*iPhone.*$
  3. RewriteRule ^(.*)$ http://www.mysite.mobi/ [R=301]
  4. RewriteCond %{HTTP_USER_AGENT} ^.*BlackBerry.*$
  5. RewriteRule ^(.*)$ http://www.mysite.mobi/ [R=301]
  6. RewriteCond %{HTTP_USER_AGENT} ^.*Palm.*$
  7. RewriteRule ^(.*)$ http://www.mysite.mobi/ [R=301]
  8.  
Which works fine however i have one URL which is:

http://www.mysite.co.uk/adminxx/login

That i dont want redirected if i go to this on my mobile. Is there a way to do this?

Cheers,
Adam
Jul 12 '11 #1
6 3355
You can add a condition to each rule to make sure the request uri does not contain /adminxx/login
Expand|Select|Wrap|Line Numbers
  1. RewriteCond %{REQUEST_URI} !^adminxx\/login 
Or, you can make it skip these rewrites if the request is for /adminxx/login
Expand|Select|Wrap|Line Numbers
  1.     #redirect mobile browsers
  2.     RewriteRule ^adminxx\/login - [S=6] #no rewrite, just skip next 6 lines
  3.     RewriteCond %{HTTP_USER_AGENT} ^.*iPhone.*$
  4.     RewriteRule ^(.*)$ http://www.mysite.mobi/ [R=301]
  5.     RewriteCond %{HTTP_USER_AGENT} ^.*BlackBerry.*$
  6.     RewriteRule ^(.*)$ http://www.mysite.mobi/ [R=301]
  7.     RewriteCond %{HTTP_USER_AGENT} ^.*Palm.*$
  8.     RewriteRule ^(.*)$ http://www.mysite.mobi/ [R=301]
Note: you'll have to watch the number 6 in [S=6] when you modify the rules later because line count could change.
See http://httpd.apache.org/docs/2.0/mod...ml#rewriterule
Jul 12 '11 #2
adamjblakey
133 100+
Thank you very much for your reply. I have tried both variations but neither seem to work. Can you see any reason why these would not work?
Jul 12 '11 #3
Try it with the starting /
Expand|Select|Wrap|Line Numbers
  1. RewriteCond %{REQUEST_URI} !^\/adminxx\/login
Expand|Select|Wrap|Line Numbers
  1. RewriteRule ^\/adminxx\/login - [S=6]
Jul 12 '11 #4
adamjblakey
133 100+
Sorry tried again but this still does not work. Any other options?
Jul 12 '11 #5
hmm, not sure what's going on.
Try turning on rewrite log and see how your request goes through the rules you have.
http://httpd.apache.org/docs/2.0/mod...tml#rewritelog
Jul 12 '11 #6
adamjblakey
133 100+
Thanks for your help so far, i dont have access to the rewrite log to turn this on as i am on a shared hosting package. Is there anything else i can do at all?
Jul 13 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Nazir | last post by:
I am trying to do something pretty simple - but can't see how it can be done in ASP.NET. I have an aspx web page with a form which opens up a new window. The web page uses code behind to build...
3
by: blu3g85 | last post by:
how to redirect a page? as in after a few sec, the page will auto direct u to another page. ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----...
5
by: darrel | last post by:
I have a 'cancel' button that should reload the current page. Ie, reset the page back to it's initial state. Is the best way to do this to simply have the event handler for that button redirect...
3
by: Big Charles | last post by:
Hi, How to redirect any page to Login.aspx? I tried writting this in web.config <authentication mode="Forms"> <forms name="aucoockie" loginUrl="wf_login.aspx" protection="All" path="/" />...
1
kamill
by: kamill | last post by:
I am strange for Ajax and i need to redirect a page threw Ajax like Java script(window.location.href="desiredlocation.php". Is there any script in Ajax. Thanking in advance kamill
2
windows_mss
by: windows_mss | last post by:
hi Programmers, In course of my project now i facing an proble that i have to Redirect the page to some other Page after the Default Session Time Expire <sessionState ...
9
by: Rambaldi | last post by:
Hi people, i'm new to php... How can i redirect a page after a button click??? This might be very trivial but i really need help with this... I'm not very good at english so if you didnt...
2
by: RuthC | last post by:
Hi, In my website there is a facility for user to create there own pages we are maintaing this url as www.mywebsite.com/mypage/user created page name ex : www.mywebsite.com/mypage/ruth user...
8
luckysanj
by: luckysanj | last post by:
Dear Sir, How can i redirect index page to wwx.site.com/me/index.php. I have not fineshed front index page work so now i want to redirect this page to my personal information which is located...
2
by: amskape | last post by:
Hi pals, I have a problem regarding the page with listing. The listing page is arranged using pagination with 3 results per page. I need to delete each entry and redirect the page to proper...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.