Zend framework 关于此htaccess文件的四个具体问题
1)在这些之前的重写规则之前,我们不需要一个条件吗?Zend framework 关于此htaccess文件的四个具体问题,zend-framework,.htaccess,Zend Framework,.htaccess,1)在这些之前的重写规则之前,我们不需要一个条件吗? #+FollowSymLinks must be enabled for any rules to work, this is a security #requirement of the rewrite engine. Normally it's enabled in the root and you #shouldn't have to add it, but it doesn't hurt to do so. Options +Fo
#+FollowSymLinks must be enabled for any rules to work, this is a security
#requirement of the rewrite engine. Normally it's enabled in the root and you
#shouldn't have to add it, but it doesn't hurt to do so.
Options +FollowSymlinks
#Apache scans all incoming URL requests, checks for matches in our .htaccess file
#and rewrites those matching URLs to whatever we specify.
#to enable runtime rewriting engine
RewriteEngine On
#this tells mod_rewrite to leave the URL unchanged (the dash part -) and quit
#other rewwrite processing rules if the requested segment has one of those
#prefixes (that's what we asking when we use the ^ sign), on the list. If the
#prefix is in the list, all subsequent Rewrite Rules are skipped.
#So to avoid some files OR directories to be redirected we use:
RewriteRule ^(somefile|somedir|someotherfile) – [L]
#this will allow direct linkage to this extensions, regardless the case sensitive.
RewriteCond %{REQUEST_FILENAME} !\.(js|ico|zip|rar|mov|mpeg4|mp4|gif|jpg|png|css|doc|pdf|docx|wmv|mpeg|avi|mpg|flv|ppt|pptx|txt)$ - [NC]
#if the request uri has not public...
RewriteCond %{REQUEST_URI} !^/public/.*$
#rewrite to public something...
RewriteRule ^(.*)$ /public/$1
2)此处[NC]标志是否会处理所有案例变化?
#+FollowSymLinks must be enabled for any rules to work, this is a security
#requirement of the rewrite engine. Normally it's enabled in the root and you
#shouldn't have to add it, but it doesn't hurt to do so.
Options +FollowSymlinks
#Apache scans all incoming URL requests, checks for matches in our .htaccess file
#and rewrites those matching URLs to whatever we specify.
#to enable runtime rewriting engine
RewriteEngine On
#this tells mod_rewrite to leave the URL unchanged (the dash part -) and quit
#other rewwrite processing rules if the requested segment has one of those
#prefixes (that's what we asking when we use the ^ sign), on the list. If the
#prefix is in the list, all subsequent Rewrite Rules are skipped.
#So to avoid some files OR directories to be redirected we use:
RewriteRule ^(somefile|somedir|someotherfile) – [L]
#this will allow direct linkage to this extensions, regardless the case sensitive.
RewriteCond %{REQUEST_FILENAME} !\.(js|ico|zip|rar|mov|mpeg4|mp4|gif|jpg|png|css|doc|pdf|docx|wmv|mpeg|avi|mpg|flv|ppt|pptx|txt)$ - [NC]
#if the request uri has not public...
RewriteCond %{REQUEST_URI} !^/public/.*$
#rewrite to public something...
RewriteRule ^(.*)$ /public/$1
3)为什么我们的规则中有$1而没有/public/index.php?
#+FollowSymLinks must be enabled for any rules to work, this is a security
#requirement of the rewrite engine. Normally it's enabled in the root and you
#shouldn't have to add it, but it doesn't hurt to do so.
Options +FollowSymlinks
#Apache scans all incoming URL requests, checks for matches in our .htaccess file
#and rewrites those matching URLs to whatever we specify.
#to enable runtime rewriting engine
RewriteEngine On
#this tells mod_rewrite to leave the URL unchanged (the dash part -) and quit
#other rewwrite processing rules if the requested segment has one of those
#prefixes (that's what we asking when we use the ^ sign), on the list. If the
#prefix is in the list, all subsequent Rewrite Rules are skipped.
#So to avoid some files OR directories to be redirected we use:
RewriteRule ^(somefile|somedir|someotherfile) – [L]
#this will allow direct linkage to this extensions, regardless the case sensitive.
RewriteCond %{REQUEST_FILENAME} !\.(js|ico|zip|rar|mov|mpeg4|mp4|gif|jpg|png|css|doc|pdf|docx|wmv|mpeg|avi|mpg|flv|ppt|pptx|txt)$ - [NC]
#if the request uri has not public...
RewriteCond %{REQUEST_URI} !^/public/.*$
#rewrite to public something...
RewriteRule ^(.*)$ /public/$1
4)由于这是最后一条规则,我们可以删除L标志吗?
#+FollowSymLinks must be enabled for any rules to work, this is a security
#requirement of the rewrite engine. Normally it's enabled in the root and you
#shouldn't have to add it, but it doesn't hurt to do so.
Options +FollowSymlinks
#Apache scans all incoming URL requests, checks for matches in our .htaccess file
#and rewrites those matching URLs to whatever we specify.
#to enable runtime rewriting engine
RewriteEngine On
#this tells mod_rewrite to leave the URL unchanged (the dash part -) and quit
#other rewwrite processing rules if the requested segment has one of those
#prefixes (that's what we asking when we use the ^ sign), on the list. If the
#prefix is in the list, all subsequent Rewrite Rules are skipped.
#So to avoid some files OR directories to be redirected we use:
RewriteRule ^(somefile|somedir|someotherfile) – [L]
#this will allow direct linkage to this extensions, regardless the case sensitive.
RewriteCond %{REQUEST_FILENAME} !\.(js|ico|zip|rar|mov|mpeg4|mp4|gif|jpg|png|css|doc|pdf|docx|wmv|mpeg|avi|mpg|flv|ppt|pptx|txt)$ - [NC]
#if the request uri has not public...
RewriteCond %{REQUEST_URI} !^/public/.*$
#rewrite to public something...
RewriteRule ^(.*)$ /public/$1
somefile
、somedir
或someotherfile
开头的文件都不会被重写(-
)<代码>[L]确保不会处理进一步的规则(包括此规则)RewriteCond
也可以匹配/public/otherthing
,而不仅仅是/public/index.php
[L]
,将发生无限循环,因为重写的URL/public/index.php
匹配`^public.*$
对于问题1、2和4,回答“是”或“否”即可:我能问一下你的意见吗?HTAccess文件有一些我需要考虑的严重问题吗?或者是否有任何我可能不知道的标准方法来完成上述工作?提前非常感谢。将
[L]
添加到关于静态文件的规则中,这些URL不必重写<代码>重写规则模式-只是表示“保留当前URL,寻找更多规则”。附加了[L]
,表示“保留当前URL,不搜索进一步重写”。