Nginx上にある既存のサイトからCodeIgniterをセットアップしようとしています。私のローカルマシンはApacheで、これはnginxのリダイレクトスキームです。 RewriteRules
を使用してこれを作成するにはどうすればよいですか?
if ($Host ~* ^www\.(.*)) {
set $Host_without_www $1;
rewrite ^(.*)$ http://$Host_without_www$1 permanent;
}
if ($request_uri ~* ^(/welcome(/index)?|/index(.php)?)/?$){
rewrite ^(.*)$ / permanent;
}
if ($request_uri ~* index/?$){
rewrite ^/(.*)/index/?$ /$1 permanent;
}
if (!-d $request_filename){
rewrite ^/(.+)/$ /$1 permanent;
}
if ($request_uri ~* ^/system){
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
このようなもの:
# These go in the VirtualHost context.
RewriteEngine On
RewriteCond %{HTTP_Host} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^(/welcome(/index)?|/index(.php)?)/?$ [NC]
RewriteRule ^ / [R=301,L]
RewriteRule ^/(.*)/index/?$ /$1 [R=301,L,NC]
RewriteCond %{REQUEST_URI} ^/system [NC]
RewriteRule ^/(.*)$ /index.php?/$1 [L]
<Directory /path/to/docroot>
# This is so that these have the correct filesystem path in the
# REQUEST_FILENAME parameter.
# If you already have a <Directory> for here, add these to it.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ $1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^/(.*)$ /index.php?/$1 [L]
</Directory>