我正在尝试nginx并将我现有的apacheconfiguration移植到nginx。 我设法重新路由codeigniterurl的成功,但我有一个特定的控制器,其名称与站点根目录一致的问题。
我设法使我的codeigniterurl的工作,因为它在Apache中,除了我有一个特定的URL说http://localhost/hello这与网站根目录中的hello目录一致。 Apache对此没有任何问题。 但是nginx路由到这个目录而不是控制器。
我的重新路由结构如下
http://host_name/incoming_url => http://host_name/index.php/incoming_url
所有codeigniter文件都在站点根目录下。
我的nginxconfiguration(相关部分)
location / { # First attempt to serve request as file, then # as directory, then fall back to index.html index index.php index.html index.htm; try_files $uri $uri/ /index.php/$request_uri; #apache rewrite rule conversion if (!-e $request_filename){ rewrite ^(.*)/?$ /index.php?/$1 last; } # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } location ~ \.php.*$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # With php5-cgi alone: fastcgi_pass 127.0.0.1:9000; # With php5-fpm: #fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; }
编辑:
我的相关的Apache Htaccess的configuration
# Set the default file for indexes DirectoryIndex index.php <IfModule mod_rewrite.c> # mod_rewrite rules RewriteEngine on # If the file is NOT the index.php file RewriteCond %{REQUEST_FILENAME} !index.php # If the file/dir is NOT real go to index RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [QSA,L] </IfModule>
我是nginx的新手,我需要帮助找出与控制器名称的这个目录冲突。 我从networking上的各种来源中find了这种configuration,我非常赞赏任何更好的编写configuration的方法。