7

I'm trying to use this .htaccess to change the RewriteBase if the location is local or live server.

Options +FollowSymlinks
RewriteEngine on

<LocationMatch "^/(bbtsrv02)/$">
    #RewriteBase /beta/admin/
</LocationMatch>

RewriteCond %{REQUEST_URI} !index.php$
RewriteCond %{REQUEST_URI} !css/(.*)\.
RewriteCond %{REQUEST_URI} !img/(.*)\.
RewriteCond %{REQUEST_URI} !incs/(.*)\.
RewriteCond %{REQUEST_URI} !js/(.*)\.
RewriteCond %{REQUEST_URI} !upload/(.*)\.
RewriteCond %{REQUEST_URI} !widget/(.*)\.
RewriteRule ^(.*) index.php?_pd=$1 [NC,L]

As soon as I remove the LocationMatch the whole thing starts working again. I only need to change the RewriteBase for live testing.

James
  • 5,137
  • 5
  • 40
  • 80

1 Answers1

15

<LocationMatch> directive CANNOT be used in .htaccess file -- only in server config or virtual host context.

http://httpd.apache.org/docs/current/mod/core.html#locationmatch

LazyOne
  • 158,824
  • 45
  • 388
  • 391
  • Durrr. You know I even read this and told myself to take a mental note of that. Thanks for pointing it out again! – James Jul 12 '11 at 11:57
  • @James How do you access your local server? I guess via subfolders. If so -- why don't you fake DNS name (via `hosts` file) and access via domain name (e.g. `http://mysite.dev/`) .. so URL structure is the same as on live server? – LazyOne Jul 12 '11 at 12:01
  • we develop on a local server machine, which we all connect to individually. I've thought about setting up `hosts` file but it's a pain when we actually want to go live. – James Jul 12 '11 at 12:03
  • @James Then do it via your local DNS server (if you have it, of course) -- then will be no need to edit hosts file. BTW -- why _"it's a pain when we actually want to go live"_? You will have 1 domain name (real) for live server and local (different) name for local development -- I'm working like that all the time with no issues. – LazyOne Jul 12 '11 at 12:06