我是 lighttpd 的初学者,由于 htaccess,我在 cms 脚本中遇到了问题,因为 htaccess 在 lighttpd 中不起作用,我在 lighttpd.conf 文件中启用了 mod_rewrite,因此我在我的网站的网页上遇到了 404 错误我的 .htaccess 文件:
Options +FollowSymLinks -Indexes
# Turn on URL rewriting
RewriteEngine On
# Installation directory
# RewriteBase /
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
# Rewrite all other URLs to index.php/URL
RewriteRule ^(.*)$ index.php?path=$1 [NC,L,QSA]
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/opentype
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 env=!dont-vary
</IfModule>
<IfModule mod_security.c>
SecFilterScanPOST Off
</IfModule>
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##
我的 lighttpd.conf(仅限服务器模块)
server. Modules = (
"mod_magnet",
"mod_indexfile",
"mod_access",
"mod_alias",
"mod_rewrite",
"mod_redirect",
# "mod_rewrite",
"mod_compress",
# "mod_magnet",
"mod_simple_vhost",
# "mod_setenv",
# "mod_rewrite",
"mod_openssl",
)
这个你能帮我吗
答案1
抱歉,但您的“.htaccess”文件未经 lighttpd 或 apache 之外的任何其他网络服务器评估。
你必须在 lighttpd.conf 中用不同的语法编写行
例子:
url.rewrite = ( "^/status$" => "/server-status" )
url.redirect = ( "^/wishlist/(.+)" => "http://www.123.org/$1" )
deflate.mimetypes = (
"text/css; charset=utf-8",
"text/css",
"text/javascript; charset=utf-8",
"text/javascript",
"text/plain; charset=utf-8",
"text/plain",
"text/html; charset=utf-8",
"text/html"
)