我有一个相当大的 htaccess,我自己写的,但是转换成 nginx 对我来说不太好,我试过了本网站转换,但在重新加载 nginx 时出现错误,
重新加载 nginx 配置:nginx:[emerg] /etc/nginx/sites-enabled/mywebsite:22 中的指令“rewrite”未以“;”结尾
这是我的完整 htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.mywebsite.org$ [NC]
RewriteRule ^(.*)$ http://mywebsite.org/$1 [R=301,L]
RewriteBase /
RewriteRule ^lang/(.*?)$ index.php?lang=$1
RewriteRule ^([a-z]{2})/?$ index.php?lang=$1
RewriteRule ^message/(.*?)$ index.php?msg=$1
RewriteRule ^add(/(.*?))?$ index.php?mode=add&msg=$2
RewriteRule ^world/?$ index.php?mode=map
RewriteRule ^advanced(/(.*?))?$ search.php?mode=advanced&msg=$2
RewriteRule ^addrecord/? record.php
RewriteRule ^updaterecord/?$ record.php?mode=edit
RewriteRule ^contributerecord/?$ record.php?mode=edit&contribution=1
RewriteRule ^search/([^/]*)/?([^/]*)/?([0-9]{2,3})/? search.php?q=$1&page=$2&limit=$3
RewriteRule ^search/([^/]*)/?([^/]*)/includes/?([^/]*)/?([^/]*)/?$ search.php?q=$1&page=$2&filter=files&includes=$3&limit=$4
RewriteRule ^search/([^/]*)/?([^/]*)/range/?([^/]*)/?([^/]*)/?([^/]*)/?$ search.php?q=$1&page=$2&filter=range&start=$3&end=$4&limit=$5
RewriteRule ^search/([^/]*)/?([^/]*)/?([^/]*)/?([^/]*)/?([^/]*)/?$ search.php?q=$1&page=$2&filter=$3&order=$4&limit=$5
RewriteRule ^avsearch/(.*?)/(.*?)/?$ search.php?mode=results&q=$1&categories=$2
RewriteRule ^location/(.*?)(/(.*?))?$ view.php?id=$1&msg=$3
RewriteRule ^lock/(.*?)$ record.php?mode=lock&id=$1
RewriteRule ^unlock/(.*?)$ record.php?mode=unlock&id=$1
RewriteRule ^edit/(.*?)$ record.php?mode=edit&id=$1
RewriteRule ^contribute/(.*?)$ record.php?mode=edit&id=$1&contribution=1
RewriteRule ^delete/(.*?)$ record.php?mode=delete&id=$1
RewriteRule ^user/(.*?)(/(.*?))?$ profile.php?mode=view&id=$1&page=$3
RewriteRule ^whoami/?$ ucp.php?mode=whoami
RewriteRule ^resend/?$ profile.php?mode=resend
RewriteRule ^request/?$ profile.php?mode=request
RewriteRule ^thread/(.*?)$ ucp.php?mode=thread&id=$1
RewriteRule ^ucp/front(/(.*?))$ ucp.php?mode=front&msg=$2
RewriteRule ^ucp/security(/(.*?))?$ ucp.php?mode=security&msg=$2
RewriteRule ^ucp(/(.*?))?(/(.*?))?$ ucp.php?mode=$2&page=$4
RewriteRule ^updateprofile/?$ profile.php?mode=update
RewriteRule ^updatepassword/?$ profile.php?mode=password
RewriteRule ^emailchange/?$ profile.php?mode=email
RewriteRule ^logout/?$ profile.php?mode=logout
RewriteRule ^login/?$ profile.php?mode=login
RewriteRule ^register/?$ profile.php?mode=register
RewriteRule ^forgotuser/?$ profile.php?mode=forgotuser
RewriteRule ^forgotpass/?$ profile.php?mode=forgotpass
RewriteRule ^rmvnotification/?$ profile.php?mode=rmvnote
RewriteRule ^updatesubrecord/?$ record.php?mode=pre&rl=1
RewriteRule ^addprerecord/?$ record.php?mode=pre
RewriteRule ^quickregister/?$ profile.php?mode=showregister
RewriteRule ^inlineregister/?$ profile.php?mode=register&return=1
RewriteRule ^activate/(.*?)/?$ profile.php?mode=activate&key=$1
RewriteRule ^reactivate/(.*?)/?(/(.*?))?$ profile.php?mode=reactivate&key=$1&msg=$3
RewriteRule ^resendpass/?$ profile.php?mode=resendpass
RewriteRule ^rss/?$ page.php?mode=rss
RewriteRule ^api/?$ page.php?mode=api
RewriteRule ^help/?$ page.php?mode=help
RewriteRule ^faq/?$ page.php?mode=faq
RewriteRule ^like/?$ profile.php?mode=like
RewriteRule ^unlike/?$ profile.php?mode=unlike
RewriteRule ^approve/?$ record.php?mode=approve
RewriteRule ^disapprove/?$ record.php?mode=disapprove
RewriteRule ^files/(.*?)(/(.*?))?$ record.php?mode=file&fid=$1&preview=$3
RewriteRule ^send(/(.*?))?$ profile.php?mode=message&msg=$2
RewriteRule ^sendmessage/?$ profile.php?mode=sendmessage
RewriteRule ^report/?$ record.php?mode=report
ErrorDocument 404 /404.html
ErrorDocument 403 /403.html
ErrorDocument 500 /500.html
RewriteRule ^sitemap.xml$ sitemap.php
RewriteRule ^privupload/?$ acp/config.php?mode=upload
RewriteRule ^3rdparty/?$ api/3rdparty.php
# Custom pages
RewriteRule ^legal/?$ page.php?mode=legal
RewriteRule ^help/?$ page.php?mode=help
RewriteRule ^about/?$ page.php?mode=about
RewriteRule ^faq/?$ page.php?mode=faq
RewriteRule ^documentation/?$ page.php?mode=documentation
这是使用在线工具进行转换的尝试:
server {
server_name mywebsite.com mywebsite.org mywebsite.info mywebsite.mobi mywebsite.net;
root /var/www/mywebsite.org/www;
index index.php index.htm index.html;
access_log off;
error_log /var/www/mywebsite.org/logs/errors.log;
if ($http_host ~* "^www.mywebsite.org$"){
set $rule_0 1$rule_0;
}
if ($rule_0 = "1"){
rewrite ^/(.*)$ http://mywebsite.org/$1 permanent;
}
rewrite ^/lang/(.*?)$ /index.php?lang=$1;
rewrite ^/([a-z]{2})/?$ /index.php?lang=$1; # THIS IS LINE 22
rewrite ^/message/(.*?)$ /index.php?msg=$1;
rewrite ^/add(/(.*?))?$ /index.php?mode=add&msg=$2;
rewrite ^/world/?$ /index.php?mode=map;
rewrite ^/advanced(/(.*?))?$ /search.php?mode=advanced&msg=$2;
rewrite ^/addrecord/? /record.php;
rewrite ^/updaterecord/?$ /record.php?mode=edit;
rewrite ^/contributerecord/?$ /record.php?mode=edit&contribution=1;
rewrite ^/search/([^/]*)/?([^/]*)/?([0-9]{2,3})/? /search.php?q=$1&page=$2&limit=$3;
rewrite ^/search/([^/]*)/?([^/]*)/includes/?([^/]*)/?([^/]*)/?$ /search.php?q=$1&page=$2&filter=files&includes=$3&limit=$4;
rewrite ^/search/([^/]*)/?([^/]*)/range/?([^/]*)/?([^/]*)/?([^/]*)/?$ /search.php?q=$1&page=$2&filter=range&start=$3&end=$4&limit=$5;
rewrite ^/search/([^/]*)/?([^/]*)/?([^/]*)/?([^/]*)/?([^/]*)/?$ /search.php?q=$1&page=$2&filter=$3&order=$4&limit=$5;
rewrite ^/avsearch/(.*?)/(.*?)/?$ /search.php?mode=results&q=$1&categories=$2;
rewrite ^/location/(.*?)(/(.*?))?$ /view.php?id=$1&msg=$3;
rewrite ^/lock/(.*?)$ /record.php?mode=lock&id=$1;
rewrite ^/unlock/(.*?)$ /record.php?mode=unlock&id=$1;
rewrite ^/edit/(.*?)$ /record.php?mode=edit&id=$1;
rewrite ^/contribute/(.*?)$ /record.php?mode=edit&id=$1&contribution=1;
rewrite ^/delete/(.*?)$ /record.php?mode=delete&id=$1;
rewrite ^/user/(.*?)(/(.*?))?$ /profile.php?mode=view&id=$1&page=$3;
rewrite ^/whoami/?$ /ucp.php?mode=whoami;
rewrite ^/resend/?$ /profile.php?mode=resend;
rewrite ^/request/?$ /profile.php?mode=request;
rewrite ^/thread/(.*?)$ /ucp.php?mode=thread&id=$1;
rewrite ^/ucp/front(/(.*?))$ /ucp.php?mode=front&msg=$2;
rewrite ^/ucp/security(/(.*?))?$ /ucp.php?mode=security&msg=$2;
rewrite ^/ucp(/(.*?))?(/(.*?))?$ /ucp.php?mode=$2&page=$4;
rewrite ^/updateprofile/?$ /profile.php?mode=update;
rewrite ^/updatepassword/?$ /profile.php?mode=password;
rewrite ^/emailchange/?$ /profile.php?mode=email;
rewrite ^/logout/?$ /profile.php?mode=logout;
rewrite ^/login/?$ /profile.php?mode=login;
rewrite ^/register/?$ /profile.php?mode=register;
rewrite ^/forgotuser/?$ /profile.php?mode=forgotuser;
rewrite ^/forgotpass/?$ /profile.php?mode=forgotpass;
rewrite ^/rmvnotification/?$ /profile.php?mode=rmvnote;
rewrite ^/updatesubrecord/?$ /record.php?mode=pre&rl=1;
rewrite ^/addprerecord/?$ /record.php?mode=pre;
rewrite ^/quickregister/?$ /profile.php?mode=showregister;
rewrite ^/inlineregister/?$ /profile.php?mode=register&return=1;
rewrite ^/activate/(.*?)/?$ /profile.php?mode=activate&key=$1;
rewrite ^/reactivate/(.*?)/?(/(.*?))?$ /profile.php?mode=reactivate&key=$1&msg=$3;
rewrite ^/resendpass/?$ /profile.php?mode=resendpass;
rewrite ^/rss/?$ /page.php?mode=rss;
rewrite ^/api/?$ /page.php?mode=api;
rewrite ^/help/?$ /page.php?mode=help;
rewrite ^/faq/?$ /page.php?mode=faq;
rewrite ^/like/?$ /profile.php?mode=like;
rewrite ^/unlike/?$ /profile.php?mode=unlike;
rewrite ^/approve/?$ /record.php?mode=approve;
rewrite ^/disapprove/?$ /record.php?mode=disapprove;
rewrite ^/files/(.*?)(/(.*?))?$ /record.php?mode=file&fid=$1&preview=$3;
rewrite ^/send(/(.*?))?$ /profile.php?mode=message&msg=$2;
rewrite ^/sendmessage/?$ /profile.php?mode=sendmessage;
rewrite ^/report/?$ /record.php?mode=report;
rewrite ^/sitemap.xml$ /sitemap.php;
rewrite ^/privupload/?$ /acp/config.php?mode=upload;
rewrite ^/3rdparty/?$ /api/3rdparty.php;
rewrite ^/legal/?$ /page.php?mode=legal;
rewrite ^/help/?$ /page.php?mode=help;
rewrite ^/about/?$ /page.php?mode=about;
rewrite ^/faq/?$ /page.php?mode=faq;
rewrite ^/documentation/?$ /page.php?mode=documentation;
location ~ \.php$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/mywebsite.org/www$fastcgi_script_name;
include fastcgi_params;
}
}
看起来问题是什么呢?
答案1
或许这个转换器也会有所帮助。