ci里新建应用app,入口文件app.php。

Nginx

这里附上vhost配置

app.52fhy.com.conf

server {
	listen       80;
	server_name  app.52fhy.com;
	index app.php;
	root /www/test/ci/;
	
	location ~ .*\.(php|php5)?$
	{
		#fastcgi_pass  unix:/tmp/php-cgi.sock;
		fastcgi_pass  127.0.0.1:9000;
		fastcgi_index app.php;
		include fastcgi.conf;
	}
	
	location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
	{
		expires 30d;
	}
	
	location ~ .*\.(js|css)?$
	{
		expires 1h;
	}

	location / {
	  if (!-e $request_filename) {
                rewrite ^/(.*)$ /app.php?/$1 last;
                break;
          }
	}
	
	access_log  /www/log/nginx/access/app.52fhy.com.log;
}


nginx重启命令为:

/usr/local/nginx/sbin/nginx -s reload

url访问示例:

http://app.52fhy.com/Test/hello

实际url为

http://app.52fhy.com/app.php/Test/hello

实现了隐藏入口文件的功能。

Apache

<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ /app.php/$1 [QSA,PT,L]
</IfModule>

相关文章:

  • 2022-12-23
  • 2021-07-06
  • 2022-12-23
  • 2021-10-14
  • 2021-09-12
  • 2021-05-30
  • 2021-09-11
  • 2021-10-13
猜你喜欢
  • 2021-07-22
  • 2022-12-23
  • 2021-05-21
  • 2021-10-29
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案