drnycqxwz63508434 2019-03-21 23:19
浏览 103
已采纳

.htaccess - 不要为API调用应用重写规则

Basically, I have a separate site for desktop and mobile. Both communicate with the single back-end. the mobile version communicates via REST APIS.

The idea is to host both sites in a single domain. www.example.com. and have the rule in .htaccess to see if the request is from mobile get site content from another folder instead of the root folder. the mobile content in inside folder /pwa.

SO when accessed from mobile domain should be www.example.com, not example.com/pwa

I tried something like this.

    Options +FollowSymlinks
    RewriteEngine on


    # Android devices
    RewriteCond %{HTTP_USER_AGENT} Android
    RewriteCond %{REQUEST_URI} !/pwa 
    RewriteRule ^(.*)$ /pwa/$1 [NC,L]

All the request from Android mobile is routed to /pwa but the problem is call to REST APIS gets failed. All rest API calls have the URL structure like

https://example.com.com/api/rest/oauth2/token/client_credentials
https://example.com.com/api/rest/categories
https://example.com.com/api/rest/user/1

How do I make it work?. If the request is from mobile only the site content should take from /pwa folder and everything else should work.

Full .htaccess file content

                    # 1.To use URL Alias you need to be running apache with mod_rewrite enabled.

    # 2. In your opencart directory rename htaccess.txt to .htaccess.

    # For any support issues please visit: http://www.opencart.com

    Options +FollowSymlinks

    # Prevent Directoy listing
    Options -Indexes

    # Prevent Direct Access to files
    <FilesMatch "(?i)((\.tpl|.twig|\.ini|\.log|(?<!robots)\.txt))">
     Require all denied
    ## For apache 2.2 and older, replace "Require all denied" with these two lines :
    # Order deny,allow
    # Deny from all
    </FilesMatch>

    # SEO URL Settings

    RewriteEngine On
    # Android devices
    RewriteCond %{HTTP_USER_AGENT} Android [NC]
    RewriteCond %{THE_REQUEST} !\s/+(pwa|api) [NC]
    RewriteRule ^ pwa%{REQUEST_URI} [L]

    # If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/

    # rule for removing www on sub domains
    RewriteCond %{HTTP_HOST} ^www\.([^.]+\.tacskey\.com)$ [NC]
    RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]

    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    RewriteBase /
    RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
    RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
    RewriteRule ^system/storage/(.*) index.php?route=error/not_found [L]
    # Sets the HTTP_AUTHORIZATION header removed by apache
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

    Header set Access-Control-Expose-Headers: x-total-count

    #REST API get token
    RewriteRule ^api/rest/oauth2/token/?([a-zA-Z0-9_]+) index.php?route=feed/rest_api/gettoken&grant_type=$1  [L]
    #REST API get token
    RewriteRule ^api/rest/oauth2/token index.php?route=feed/rest_api/gettoken  [L]
    #REST API database tables checksum
    RewriteRule ^api/rest/checksums index.php?route=feed/rest_api/getchecksum  [L]
    RewriteRule ^api/rest/affiliate index.php?route=feed/rest_api/affiliate  [L]
    ####################################### OPENCART UTC OFFSET #################################################
    #REST API UTC and server time offset in seconds
    RewriteRule ^api/rest/utc_offset index.php?route=feed/rest_api/utc_offset  [L]
    #######################################VOUCHER THEMES#####################################################
    #REST API voucher themes
    RewriteRule ^api/rest/account/voucherthemes index.php?route=rest/account/voucherthemes  [L]
    #######################################VOUCHERS#####################################################
    #REST API vouchers
    RewriteRule ^api/rest/account/voucher index.php?route=rest/account/voucher  [L]
    #######################################TRANSACTIONS#####################################################
    #REST API transactions
    RewriteRule ^api/rest/account/transactions index.php?route=rest/account/transactions  [L]
    ####################################### OPENCART ORDER STATUSES #################################################
    #REST API List order statuses
    RewriteRule ^api/rest/order_statuses index.php?route=feed/rest_api/order_statuses  [L]
    #######################################PRODUCT######################################################################
    #REST API product custom search pager
    RewriteRule ^api/rest/products/custom_search/limit/?([0-9]+)/page/?([0-9]+) index.php?route=feed/rest_api/search&limit=$1&page=$2 [L]
    #REST API product custom search
    RewriteRule ^api/rest/products/custom_search index.php?route=feed/rest_api/search[L]
    RewriteRule ^api/rest/products/search/?([-a-zA-Z0-9_&\|\s/.]+)/sort/?([a-zA-Z]+)/order/?([a-zA-Z]+) index.php?route=feed/rest_api/products&search=$1&sort=$2&order=$3 [B,NC,L]
    RewriteRule ^api/rest/products/search/?([-a-zA-Z0-9_&\|\s/.]+)/sort/?([a-zA-Z]+) index.php?route=feed/rest_api/products&search=$1&sort=$2 [B,NC,L]
    RewriteRule ^api/rest/products/category/?([0-9]+)/sort/?([a-zA-Z]+)/order/?([a-zA-Z]+) index.php?route=feed/rest_api/products&category=$1&sort=$2&order=$3  [L]
    RewriteRule ^api/rest/products/category/?([0-9]+)/sort/?([a-zA-Z]+) index.php?route=feed/rest_api/products&category=$1&sort=$2  [L]
    RewriteRule ^api/rest/products/sort/?([a-zA-Z]+)/order/?([a-zA-Z]+) index.php?route=feed/rest_api/products&sort=$1&order=$2  [L]
    RewriteRule ^api/rest/products/sort/?([a-zA-Z]+) index.php?route=feed/rest_api/products&sort=$1  [L]
    #REST API products filter by slug
    RewriteRule ^api/rest/products/slug/?([-a-zA-Z0-9_&\|\s/.]+) index.php?route=feed/rest_api/products&slug=$1 [B,NC,L]
    #REST API add review
    RewriteRule ^api/rest/products/?([0-9]+)/review index.php?route=feed/rest_api/reviews&id=$1  [L]
    #REST API product search pager
    RewriteRule ^api/rest/products/search/?([-a-zA-Z0-9_&\|\s/.]+)/limit/?([0-9]+)/page/?([0-9]+) index.php?route=feed/rest_api/products&search=$1&limit=$2&page=$3 [B,NC,L]
    #REST API product search
    RewriteRule ^api/rest/products/search/?([-a-zA-Z0-9_&\|\s/.]+) index.php?route=feed/rest_api/products&search=$1 [B,NC,L]
    #REST API product pager
    RewriteRule ^api/rest/products/limit/?([0-9]+)/page/?([0-9]+) index.php?route=feed/rest_api/products&limit=$1&page=$2  [L]
    #REST API product per category pager
    RewriteRule ^api/rest/products/category/?([0-9]+)/limit/?([0-9]+)/page/?([0-9]+) index.php?route=feed/rest_api/products&category=$1&limit=$2&page=$3  [L]
    #REST API products by category filters
    RewriteRule ^api/rest/products/category/?([0-9]+)/filters/([0-9,?:,]+) index.php?route=feed/rest_api/products&category=$1&filters=$2  [L]
    #REST API products per category
    RewriteRule ^api/rest/products/category/?([0-9]+) index.php?route=feed/rest_api/products&category=$1  [L]
    #REST API selected product
    RewriteRule ^api/rest/products/?([0-9]+) index.php?route=feed/rest_api/products&id=$1  [L]
    #REST API custom fields
    RewriteRule ^api/rest/products/simple/customfields/?([a-zA-Z0-9,\s]+) index.php?route=feed/rest_api/products&simple=1&custom_fields=$1  [L]
    #REST API simple products
    RewriteRule ^api/rest/products/simple index.php?route=feed/rest_api/products&simple=1  [L]
    #REST API product per manufacturer pager
    RewriteRule ^api/rest/products/manufacturer/?([0-9]+)/limit/?([0-9]+)/page/?([0-9]+) index.php?route=feed/rest_api/products&manufacturer=$1&limit=$2&page=$3  [L]
    #REST API products per manufacturer
    RewriteRule ^api/rest/products/manufacturer/?([0-9]+) index.php?route=feed/rest_api/products&manufacturer=$1  [L]
    #REST API products
    RewriteRule ^api/rest/products index.php?route=feed/rest_api/products  [L]
    #REST API get featured products limit
    RewriteRule ^api/rest/featured/limit/?([0-9]+) index.php?route=feed/rest_api/featured&limit=$1  [L]
    #REST API get featured products
    RewriteRule ^api/rest/featured index.php?route=feed/rest_api/featured  [L]
    RewriteRule ^api/rest/custom index.php?route=feed/rest_api/custom  [L]
    #REST API get product classes
    RewriteRule ^api/rest/product_classes index.php?route=feed/rest_api/productclasses  [L]
    #REST API bestsellers
    RewriteRule ^api/rest/bestsellers/limit/?([0-9]+) index.php?route=feed/rest_api/bestsellers&limit=$1  [L]
    #REST API bestsellers
    RewriteRule ^api/rest/bestsellers index.php?route=feed/rest_api/bestsellers  [L]
    #REST API filters
    RewriteRule ^api/rest/filters/id/?([0-9]+) index.php?route=feed/rest_api/filters&id=$1  [L]
    #REST API related
    RewriteRule ^api/rest/related/?([0-9]+) index.php?route=feed/rest_api/related&id=$1  [L]
    #REST API latest
    RewriteRule ^api/rest/latest/limit/?([0-9]+) index.php?route=feed/rest_api/latest&limit=$1  [L]
    RewriteRule ^api/rest/latest index.php?route=feed/rest_api/latest  [L]
    #REST API banners
    RewriteRule ^api/rest/banners/?([0-9]+) index.php?route=feed/rest_api/banners&id=$1  [L]
    RewriteRule ^api/rest/banners index.php?route=feed/rest_api/banners  [L]
    #REST API specials
    RewriteRule ^api/rest/specials/limit/?([0-9]+) index.php?route=feed/rest_api/specials&limit=$1  [L]
    RewriteRule ^api/rest/specials index.php?route=feed/rest_api/specials  [L]
    #REST API compare products
    RewriteRule ^api/rest/compare/([0-9,?:,]+) index.php?route=feed/rest_api/compare&ids=$1  [L]
    #######################################SLIDESHOW####################################################################
    #REST API get slideshows
    RewriteRule ^api/rest/slideshows index.php?route=feed/rest_api/slideshows  [L]
    #######################################CATEGORY####################################################################
    #REST API categories filter by slug
    RewriteRule ^api/rest/categories/slug/?([-a-zA-Z0-9_&\|\s/.]+) index.php?route=feed/rest_api/categories&slug=$1 [B,NC,L]
    #REST API categories filter parent and level
    RewriteRule ^api/rest/categories/parent/?([0-9]+)/level/?([0-9]+) index.php?route=feed/rest_api/categories&parent=$1&level=$2  [L]
    #REST API categories filter level
    RewriteRule ^api/rest/categories/level/?([0-9]+) index.php?route=feed/rest_api/categories&level=$1  [L]
    #REST API categories filter parent
    RewriteRule ^api/rest/categories/parent/?([0-9]+) index.php?route=feed/rest_api/categories&parent=$1  [L]
    #REST API selected category
    RewriteRule ^api/rest/categories/?([0-9]+) index.php?route=feed/rest_api/categories&id=$1  [L]
    RewriteRule ^api/rest/categories/extended/limit/?([0-9]+)/page/?([0-9]+) index.php?route=feed/rest_api/categories&limit=$1&page=$2&extended=1  [L]
    #REST API categories
    RewriteRule ^api/rest/categories index.php?route=feed/rest_api/categories [L]
    #######################################MANUFACTURER#################################################################
    #REST API selected manufacturer
    RewriteRule ^api/rest/manufacturers/?([0-9]+) index.php?route=feed/rest_api/manufacturers&id=$1  [L]
    #REST API manufacturers
    RewriteRule ^api/rest/manufacturers index.php?route=feed/rest_api/manufacturers  [L]
    RewriteRule ^api/rest/coupons index.php?route=feed/rest_api/coupons  [L]
    #######################################ORDERS######################################################################
    #REST API order history
    RewriteRule ^api/rest/orderhistory/?([0-9]+) index.php?route=feed/rest_api/orderhistory&id=$1  [L]
    #REST API selected orders
    #RewriteRule ^api/rest/orders/?([0-9]+) index.php?route=feed/rest_api/orders&id=$1  [L]
    #REST API Orders with details filter by date_added range
    #RewriteRule ^api/rest/orders/details/added_from/([^/]+)/added_to/([^/]+)/?$ index.php?route=feed/rest_api/listorderswithdetails&filter_date_added_from=$1&filter_date_added_to=$2 [L]
    #REST API Orders with details filter by date_added from till now
    #RewriteRule ^api/rest/orders/details/added_from/([^/]+)/?$ index.php?route=feed/rest_api/listorderswithdetails&filter_date_added_from=$1 [L]
    #REST API Orders with details filter by date_added on
    #RewriteRule ^api/rest/orders/details/added_on/([^/]+)/?$ index.php?route=feed/rest_api/listorderswithdetails&filter_date_added_on=$1 [L]
    #REST API Orders with details filter by date_modified range
    #RewriteRule ^api/rest/orders/details/modified_from/([^/]+)/modified_to/([^/]+)/?$ index.php?route=feed/rest_api/listorderswithdetails&filter_date_modified_from=$1&filter_date_modified_to=$2 [L]
    #REST API Orders with details filter by date_modified from till now
    #RewriteRule ^api/rest/orders/details/modified_from/([^/]+)/?$ index.php?route=feed/rest_api/listorderswithdetails&filter_date_modified_from=$1 [L]
    #REST API Orders with details filter by date_modified on
    #RewriteRule ^api/rest/orders/details/modified_on/([^/]+)/?$ index.php?route=feed/rest_api/listorderswithdetails&filter_date_modified_on=$1 [L]
    #REST API Orders with details filter by status
    #RewriteRule ^api/rest/orders/details/status/([0-9,?:,]+) index.php?route=feed/rest_api/listorderswithdetails&filter_order_status_id=$1 [L]
    #REST API Orders with details
    #RewriteRule ^api/rest/orders/details index.php?route=feed/rest_api/listorderswithdetails  [L]
    #REST API update order status
    #RewriteRule ^api/rest/order_status/?([0-9]+) index.php?route=feed/rest_api/orderstatus&id=$1  [L]
    #REST API Orders filtered by user
    #RewriteRule ^api/rest/orders/user/?([0-9]+) index.php?route=feed/rest_api/userorders&user=$1  [L]
    #REST API orders
    #RewriteRule ^api/rest/orders index.php?route=feed/rest_api/orders  [L]
    #######################################CUSTOMERS##################################################################
    #REST API selected customers
    RewriteRule ^api/rest/customers/?([0-9]+) index.php?route=feed/rest_api/customers&id=$1  [L]
    #REST API customers
    RewriteRule ^api/rest/customers index.php?route=feed/rest_api/customers  [L]
    #######################################LANGUAGES#################################################################
    #REST API selected language
    RewriteRule ^api/rest/languages/?([0-9]+) index.php?route=feed/rest_api/languages&id=$1  [L]
    #REST API languages
    RewriteRule ^api/rest/languages index.php?route=feed/rest_api/languages [L]
    ##############################################STORE###############################################################
    #REST API selected store
    RewriteRule ^api/rest/stores/?([0-9]+) index.php?route=feed/rest_api/stores&id=$1  [L]
    #REST API stores
    RewriteRule ^api/rest/stores index.php?route=feed/rest_api/stores [L]
    #######################################COUNTRY###################################################################
    #REST API selected country
    RewriteRule ^api/rest/countries/?([0-9]+) index.php?route=feed/rest_api/countries&id=$1  [L]
    #REST API countries
    RewriteRule ^api/rest/countries index.php?route=feed/rest_api/countries [L]
    #######################################SESSION#####################################################################
    #REST API get session
    RewriteRule ^api/rest/session index.php?route=feed/rest_api/session  [L]
    #######################################CART####################################################
    #REST API cart bulk functions
    RewriteRule ^api/rest/cart_bulk index.php?route=rest/cart/bulkcart  [L]
    #REST API empty cart
    RewriteRule ^api/rest/cart/empty index.php?route=rest/cart/emptycart  [L]
    #REST API delete cart item by id
    RewriteRule ^api/rest/cart/?([a-zA-Z0-9,\s]+) index.php?route=rest/cart/cart&key=$1  [L]
    #REST API cart
    RewriteRule ^api/rest/cart/update index.php?route=rest/cart/updatecartv2  [L]
    #REST API cart
    RewriteRule ^api/rest/cart index.php?route=rest/cart/cart  [L]
    #######################################CUSTOMERS####################################################
    #REST API registration
    RewriteRule ^api/rest/register index.php?route=rest/register/register  [L]
    #REST API login
    RewriteRule ^api/rest/login index.php?route=rest/login/login  [L]
    #REST API social login
    RewriteRule ^api/rest/sociallogin index.php?route=rest/login/sociallogin  [L]
    #REST API logout
    RewriteRule ^api/rest/logout index.php?route=rest/logout/logout  [L]
    #REST API forgotten password
    RewriteRule ^api/rest/forgotten index.php?route=rest/forgotten/forgotten  [L]
    #REST API multivendor registration
    RewriteRule ^api/rest/multivendor_signup index.php?route=rest/multivendor/register  [L]
    #REST API multivendor infos
    RewriteRule ^api/rest/multivendor_infos index.php?route=rest/multivendor/infos  [L]
    #######################################VOUCHER####################################################
    #REST API add voucher
    RewriteRule ^api/rest/voucher index.php?route=rest/cart/voucher  [L]
    #######################################COUPON####################################################
    #REST API add coupon
    RewriteRule ^api/rest/coupon index.php?route=rest/cart/coupon  [L]
    #######################################REWARD#####################################################
    #REST API add reward
    RewriteRule ^api/rest/reward index.php?route=rest/cart/reward  [L]
    #######################################GUEST SHIPPING ####################################################
    #REST API payment methods
    RewriteRule ^api/rest/guestshipping index.php?route=rest/guest_shipping/guestshipping  [L]
    #######################################GUEST####################################################
    #REST API guest
    RewriteRule ^api/rest/guest index.php?route=rest/guest/guest  [L]
    #######################################PAYMENT METHOD####################################################
    #REST API payment methods
    RewriteRule ^api/rest/paymentmethods index.php?route=rest/payment_method/payments  [L]
    #######################################PAYMENT ADDRESS####################################################
    #REST API payment address
    RewriteRule ^api/rest/paymentaddress/existing index.php?route=rest/payment_address/paymentaddress&existing=1  [L]
    RewriteRule ^api/rest/paymentaddress index.php?route=rest/payment_address/paymentaddress  [L]
    #######################################SHIPPING ADDRESS####################################################
    #REST API shipping address
    RewriteRule ^api/rest/shippingaddress/existing index.php?route=rest/shipping_address/shippingaddress&existing=1   [L]
    RewriteRule ^api/rest/shippingaddress index.php?route=rest/shipping_address/shippingaddress  [L]
    #######################################SHIPPING METHOD####################################################
    #REST API shipping methods
    RewriteRule ^api/rest/shippingmethods index.php?route=rest/shipping_method/shippingmethods  [L]
    #######################################ZONE####################################################
    #REST API get zones
    RewriteRule ^api/rest/zone/?([0-9]+) index.php?route=rest/guest/zone&country_id=$1 [L]
    #######################################CHECKOUT CONFIRM############################################
    #REST API confirm and save order
    RewriteRule ^api/rest/confirm index.php?route=rest/confirm/confirm  [L]
    #######################################CHECKOUT CONFIRM SIMPLE############################################
    #REST API confirm and save order
    RewriteRule ^api/rest/simpleconfirm index.php?route=rest/simple_confirm/confirm  [L]
    #######################################CHECKOUT USERDATA TEST ############################################
    #REST API check user data
    RewriteRule ^api/rest/checkuser index.php?route=rest/login/checkuser  [L]
    ####################################### CUSTOMER ORDERS ####################################################
    RewriteRule ^api/rest/customerorders/limit/?([0-9]+)/page/?([0-9]+) index.php?route=rest/order/orders&limit=$1&page=$2 [L]
    RewriteRule ^api/rest/customerorders/?([0-9]+)/product_id/?([0-9]+) index.php?route=rest/order/orders&id=$1&order_product_id=$2  [L]
    #REST API customer orders details or reorder
    RewriteRule ^api/rest/customerorders/?([0-9]+) index.php?route=rest/order/orders&id=$1  [L]
    #REST API customer orders
    RewriteRule ^api/rest/customerorders index.php?route=rest/order/orders  [L]
    #######################################CHANGE PASSWORD####################################################
    RewriteRule ^api/rest/account/address/?([0-9]+) index.php?route=rest/account/address&id=$1  [L]
    #REST API address method
    RewriteRule ^api/rest/account/address index.php?route=rest/account/address  [L]
    #REST API change password method
    RewriteRule ^api/rest/account/password index.php?route=rest/account/password  [L]
    #######################################GUEST ACCOUNT ####################################################
    RewriteRule ^api/rest/account/recurrings/?([0-9]+) index.php?route=rest/account/recurrings&id=$1  [L]
    RewriteRule ^api/rest/account/recurrings/limit/?([0-9]+)/page/?([0-9]+) index.php?route=rest/account/recurrings&limit=$1&page=$2 [L]
    RewriteRule ^api/rest/account/recurrings index.php?route=rest/account/recurrings [L]
    RewriteRule ^api/rest/account/downloads/limit/?([0-9]+)/page/?([0-9]+) index.php?route=rest/account/downloads&limit=$1&page=$2 [L]
    RewriteRule ^api/rest/account/downloads index.php?route=rest/account/downloads [L]
    #REST API account methods
    RewriteRule ^api/rest/account index.php?route=rest/account/account  [L]
    #REST API account custom fields
    RewriteRule ^api/rest/customfield index.php?route=rest/account/customfield  [L]
    #######################################WISHLIST####################################################
    #REST API add product to wishlist or delete from wishlist
    RewriteRule ^api/rest/wishlist/?([0-9]+) index.php?route=rest/wishlist/wishlist&id=$1  [L]
    #REST API wishlist
    RewriteRule ^api/rest/wishlist index.php?route=rest/wishlist/wishlist  [L]
    #######################################REST API START PAYMENT PROCESS####################################################
    RewriteRule ^api/rest/pay index.php?route=rest/confirm/confirm&page=pay  [L]
    #######################################Contact##############################
    #REST API contact
    RewriteRule ^api/rest/contact index.php?route=rest/contact/send  [L]
    #######################################INFORMATION#################################################################
    #REST API selected information
    RewriteRule ^api/rest/information/?([0-9]+) index.php?route=feed/rest_api/information&id=$1  [L]
    #REST API information
    RewriteRule ^api/rest/information index.php?route=feed/rest_api/information  [L]
    #######################################RETURN#################################################################
    #REST API selected return
    RewriteRule ^api/rest/returns/?([0-9]+) index.php?route=rest/return/returns&id=$1  [L]
    #REST API returns
    RewriteRule ^api/rest/returns index.php?route=rest/return/returns  [L]
    #######################################NEWSLETTER#################################################################
    #REST API newsletter
    RewriteRule ^api/rest/newsletter/subscribe index.php?route=rest/account/newsletter&subscribe=1  [L]
    RewriteRule ^api/rest/newsletter/unsubscribe index.php?route=rest/account/newsletter&subscribe=0  [L]
    #######################################SHIPPING QUOTES######################################################
    #REST API shipping quotes
    RewriteRule ^api/rest/shippingquotes/?([a-zA-Z0-9.\s]+) index.php?route=rest/cart/shippingquotes&id=$1  [L]
    RewriteRule ^api/rest/shippingquotes index.php?route=rest/cart/shippingquotes  [L]
    #######################################Shopping Cart Rest API END####################################
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
    RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

    # gzip #
    <IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/text text/html text/javascript text/plain text/xml application/xml text/css application/x-javascript application/javascript
    # remove browser bugs
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    Header append Vary User-Agent
    </IfModule>
    # gzip end #

    # Turn on Expires and set default to 0
    ExpiresActive On
    ExpiresDefault A0

    # Set up caching on media files for 1 week
    <FilesMatch "\.(gif|jpg|jpeg|png)$">
      ExpiresDefault A604800
      Header append Cache-Control "public"
    </FilesMatch>

    # Set up 1 week caching on javascript and CSS
    <FilesMatch "\.(js|css)$">
      ExpiresDefault A604800
      Header append Cache-Control "proxy-revalidate"
      SetOutputFilter DEFLATE
    </FilesMatch>

    # Force no caching for dynamic files
    <FilesMatch "\.(php)$">
      ExpiresActive Off
      Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
      Header set Pragma "no-cache"
    </FilesMatch>

    ### Additional Settings that may need to be enabled for some servers
    ### Uncomment the commands by removing the # sign in front of it.
    ### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.

    # 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
    # php_flag register_globals off

    # 2. If your cart has magic quotes enabled, This may work to disable it:
    # php_flag magic_quotes_gpc Off

    # 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
    # php_value upload_max_filesize 999M

    # 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
    # php_value post_max_size 999M

    # 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
    # php_value max_execution_time 200

    # 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
    # php_value max_input_time 200

    # 7. disable open_basedir limitations
    # php_admin_value open_basedir none

Please help!

  • 写回答

2条回答 默认 最新

  • douhong4452 2019-03-22 06:15
    关注

    You may use this rule to to skip /pwa and /api for requests coming from Android:

    # Android devices
    RewriteCond %{HTTP_USER_AGENT} Android [NC]
    RewriteCond %{THE_REQUEST} !\s/+(pwa|api) [NC]
    RewriteRule !^pwa/ pwa%{REQUEST_URI} [L,NC]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 wpf中在模版中寻找元素
  • ¥15 MFC平台生成指定圆
  • ¥15 jmeter出现403
  • ¥500 求华为P30PRO手机硬盘数据恢复
  • ¥15 关于#vscode#的问题:ESP32开发板对接MQTT实现小灯泡的开关
  • ¥15 TMC2209串口模式下读取不到寄存器的值串口助手蓝色字体是发过去的消息,绿色字体是收到的消息,第二行发送读取寄存器的指令但是没有读取到寄存器的值串口助手如下图:接线如下图,如何解决?
  • ¥15 怎样删除 右键菜单里的 剪切(T)和复制(C)
  • ¥15 高通安卓11提取完整线刷包软件,或者优博讯dt50顺丰刷机包
  • ¥20 C,有个译码器,换了信道就跑不出原来数据
  • ¥15 MIMIC数据库安装问题