使用Zend Skeleten应用程序并在.htaccess中具有以下规则。
RewriteEngine On
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
尝试将加速仅限制为4个特定网址
/
(索引页)/login
/register
/auth
(授权页面)添加
RewriteCond %{REQUEST_URI} !register$
RewriteCond %{REQUEST_URI} !login$
RewriteCond %{REQUEST_URI} !index$
RewriteCond %{REQUEST_URI} !auth$
RewriteRule ^(.+)$ /chat/ [NC]
但这似乎不起作用。
localhost/test
或localhost/test/index
localhost/test/login
localhost/test/register
localhost/test/auth
问题
localhost / test /与localhost / test / index和localhost / test / index / index相同 为localhost / test / login保存,与localhost / test / login / index相同。试图在.htaccess中实现这一点。但它似乎没有工作[OR]条件。
RewriteCond %{REQUEST_URI} !^/test/(register|login|index|auth)$ [OR]
RewriteCond %{REQUEST_URI} !^/test/(register|login|index|auth)/(index)$ [OR] **edited**
RewriteCond %{REQUEST_URI} !^/test/$
RewriteRule ^ - [F]
已解决的问题
RewriteCond %{REQUEST_URI} !^/test/(\/|register|register/index|login|login/index|index|index/index|auth|auth/index|)$
RewriteRule ^ - [F]
答案 0 :(得分:1)
您可以拥有此规则:
RewriteCond %{REQUEST_URI} !(register|login|index|auth)$
RewriteRule ^ - [F]