Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9003709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:44:46+00:00 2026-06-16T00:44:46+00:00

I’m trying to do a few different things with my .htaccess file, but since

  • 0

I’m trying to do a few different things with my .htaccess file, but since it’s still somewhat new to me I’m having some trouble making everything do what I want. Here’s what I’m having trouble with…

1) I want to redirect to my mobile site for mobile devices, except in the case that the mobile device is running Opera Mini. I’ve tried to resolve that, but it’s still redirecting Opera Mini. Here’s what I have to redirect (based on code I got from this site. this code works)

# Detect if the user is on a mobile device
RewriteCond %{HTTP_USER_AGENT} android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge\ |maemo|midp|mmp|opera\ mobi|palm(\ os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows\ (ce|phone)|xda|xiino [NC,OR]
# If user is mobile, redirect to mobile site, preserving the remainder of the URL
# For example, http://www.triadbarspecials.com/barname redirects to http://m.triadbarspecials.com/barname
RewriteRule ^(.*)$ http://m.triadbarspecials.com/$1 [L,R=302,nc]

So, I wanted to make sure that Opera Mini is always directed to my Full Website, so I added the following code:

# Detect if we're in Opera Mobile
RewriteCond %{HTTP_USER_AGENT} opera\ mini
# If so, make sure user is on the main site
RewriteRule ^(.*)$ http://www.triadbarspecials.com/$1 [L,R=302,nc]

Can anyone see what’s going on there that’s causing that to not direct to the main site?

2) I have my site set up so that users can type the name of a bar after the .com/ part of the URL, and if that bar exists on my site, .htaccess will route the user to the correct page.
For example, triadbarspecials.com/justinsbar is the same as triadbarspecials.com/bars.php?barname=justinsbar

I’m having issues with my error documents not working properly. If the user types the name of a bar that doesn’t exist on my site, then the URL still directs to the page, but no dynamic content is displayed since there’s no bar by that name. User is also directed to that page for ANYTHING that’s typed after triadbarspecials.com/ as long as the URL they type does not exist. Here’s the code I have for this…

# The following allows for URL's to be typed as just the bar's name
# for example, http://www.triadbarspecials.com/bars.php?barname=barname is changed to     http://www.triadbarspecials.com/barname
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ bars.php?barname=$1 [L]

I can see that this code looks generalized, so hopefully someone can help shore this up and get things redirecting properly. Here’s what I have for the error docs

ErrorDocument 400 /error.php?error=400
ErrorDocument 401 /error.php?error=401
ErrorDocument 403 /error.php?error=403
ErrorDocument 404 /error.php?error=404
ErrorDocument 500 /error.php?error=500

3) I have this code in my .htaccess file, and I’ve completely forgotten what it does. I don’t want to just delete it, so hopefully someone can explain what it does…

RewriteCond %{HTTP_HOST} ^triadbarspecials.com[nc]
RewriteRule ^(.*)$ http:#www.triadbarspecials.com/$1 [r=301,nc]

Thanks in advance to anyone who can help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:44:47+00:00Added an answer on June 16, 2026 at 12:44 am
    1. According to this link the user-agent for Opera Mini contains both the strings “opera mini” and “opera mobi”, and you’re matching against the second one in your first redirect. That means your “Opera mini” device gets redirected to the mobile site and the second rule will never get applied. You should get rid of the second redirect and combine the 2 conditions:

      # Detect if the user is on a mobile device
      RewriteCond %{HTTP_USER_AGENT} android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge\ |maemo|midp|mmp|opera\ mobi|palm(\ os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows\ (ce|phone)|xda|xiino [NC]
      # As long as it's NOT opera mini
      RewriteCond %{HTTP_USER_AGENT} !opera\ mini [NC]
      # If user is mobile, redirect to mobile site, preserving the remainder of the URL
      # For example, http://www.triadbarspecials.com/barname redirects to http://m.triadbarspecials.com/barname
      RewriteRule ^(.*)$ http://m.triadbarspecials.com/$1 [L,R=302,nc]
      
    2. You have to do the check if the bar exists in your bars.php script. Inside that script, if the bar requested by the barname parameter doesn’t exist, then redirect the browser to /error.php?error=404. You can’t do this strictly within mod_rewrite because the rule has no idea whether the barname exists in your database or not. Mod_rewrite doesn’t have inherent access to your database.

    3. It’s redirecting requests to your site with the www missing from the hostname to the hostname with the www. So if someone types in:

      http://triadbarspecials.com/somebar
      

      they get redirected to:

      http://www.triadbarspecials.com/somebar
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.