Url的重写

nginx的配置文件

  1. [root@localhost protected]# vim /etc/nginx/conf.d/default.conf
  2. server {
  3. listen       80;
  4. server_name  localhost;
  5. #charset koi8-r;
  6. #access_log  /var/log/nginx/log/host.access.log  main;
  7. location = /favicon.ico {
  8. log_not_found off;
  9. access_log off;
  10. }
  11. location = /robots.txt {
  12. allow all;
  13. log_not_found off;
  14. access_log off;
  15. }
  16. location / {
  17. try_files $uri $uri/ /index.php?$args;
  18. if (!-e $request_filename){
  19.              rewrite ^/(.*)$ /index.php?r=$1 last;
  20.         }
  21. root   /usr/share/nginx/html;
  22. index  index.php  index.html  index.htm;
  23. }
  24. location ~ /(protected|framework|nbproject|themes/\w+/views|index-test\.php) {
  25. deny all;
  26. # for production
  27. internal;
  28. log_not_found off;
  29. access_log off;
  30. }
  31. #error_page  404              /404.html;
  32. # redirect server error pages to the static page /50x.html
  33. #
  34. error_page   500 502 503 504  /50x.html;
  35. location = /50x.html {
  36. root   /usr/share/nginx/html;
  37. }
  38. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  39. #
  40. #location ~ \.php$ {
  41. #    proxy_pass   http://127.0.0.1;
  42. #}
  43. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  44. #
  45. location ~ \.php$ {
  46. root           /usr/share/nginx/html;
  47. include  fastcgi_params;
  48. fastcgi_pass   127.0.0.1:9000;
  49. fastcgi_index  index.php;
  50. fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name;
  51. # include        fastcgi_params;
  52. }
  53. # deny access to .htaccess files, if Apache's document root
  54. # concurs with nginx's one
  55. #
  56. #location ~ /\.ht {
  57. #    deny  all;
  58. #}
  59. # deny access to .htaccess files, if Apache's document root
  60. # concurs with nginx's one
  61. #
  62. location ~ /(\.svn|\.git|\.ht|\.DS) {
  63. deny all;
  64. internal;
  65. }
  66. }

yii的配置文件

  1. /project/protected/config/main.php
  2. <?php
  3. // uncomment the following to define a path alias
  4. // Yii::setPathOfAlias('local','path/to/local-folder');
  5. // This is the main Web application configuration. Any writable
  6. // CWebApplication properties can be configured here.
  7. return array(
  8. 'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
  9. 'name'=>'My Web Application',
  10. // preloading 'log' component
  11. 'preload'=>array('log'),
  12. // autoloading model and component classes
  13. 'import'=>array(
  14. 'application.models.*',
  15. 'application.components.*',
  16. ),
  17. 'modules'=>array(
  18. // uncomment the following to enable the Gii tool
  19. /*
  20. 'gii'=>array(
  21. 'class'=>'system.gii.GiiModule',
  22. 'password'=>'Enter Your Password Here',
  23. // If removed, Gii defaults to localhost only. Edit carefully to taste.
  24. 'ipFilters'=>array('127.0.0.1','::1'),
  25. ),
  26. */
  27. ),
  28. // application components
  29. 'components'=>array(
  30. 'user'=>array(
  31. // enable cookie-based authentication
  32. 'allowAutoLogin'=>true,
  33. ),
  34. // uncomment the following to enable URLs in path-format
  35. 'urlManager'=>array(
  36. 'urlFormat'=>'path',
  37. 'showScriptName' => false,
  38. 'urlSuffix' => '.html',
  39. 'rules'=>array(
  40. '<controller:\w+>/<id:\d+>'=>'<controller>/view',
  41. '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
  42. '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
  43. ),
  44. ),
  45. // database settings are configured in database.php
  46. 'db'=>require(dirname(__FILE__).'/database.php'),
  47. 'errorHandler'=>array(
  48. // use 'site/error' action to display errors
  49. 'errorAction'=>'site/error',
  50. ),
  51. 'log'=>array(
  52. 'class'=>'CLogRouter',
  53. 'routes'=>array(
  54. array(
  55. 'class'=>'CFileLogRoute',
  56. 'levels'=>'error, warning',
  57. ),
  58. // uncomment the following to show log messages on web pages
  59. /*
  60. array(
  61. 'class'=>'CWebLogRoute',
  62. ),
  63. */
  64. ),
  65. ),
  66. ),
  67. // application-level parameters that can be accessed
  68. // using Yii::app()->params['paramName']
  69. 'params'=>array(
  70. // this is used in contact page
  71. 'adminEmail'=>'webmaster@example.com',
  72. ),
  73. );

重启nginx

    1. [root@localhost protected]# service nginx restart
    2. 停止 nginx:                                               [确定]
    3. 正在启动 nginx:                                           [确定]

最新文章

  1. ExtJS 4.2 第一个程序
  2. c#:如何处理对对象进行深度拷贝
  3. 【转】深入 Docker:容器和镜像
  4. CSS水平垂直居中的几种方法2
  5. Elasticsearch 安装与启动
  6. AJAX案例三:处理XML响应
  7. 分享一个基于HTML5实现的视频播放器【转】
  8. How to evaluate a transimpedance amplifier (part 2)
  9. (easy)LeetCode 219.Contains Duplicate II
  10. unison+inotify实现文件双向自动同步
  11. C#格式化输出
  12. C++中各种&lt;string,T&gt;关联方式的速度对比
  13. openerp 报表字段 report_rml_content_data
  14. jQuery和DOM对象
  15. C++小知识之Vector排序
  16. HDU 4642 (13.08.25)
  17. 熟人Dubbo 系列1-Dubbo什么
  18. 一个初学者的辛酸路程-python操作SQLAlchemy-13
  19. origin中把多个拟合曲线放在一张图
  20. 关于一些基础的Java问题的解答(五)

热门文章

  1. locust===注意事项
  2. jsp页面点击打印按钮调用系统 的打印功能
  3. iptables 用法及常用模块总结
  4. redis使用中的常见错误
  5. [设计模式-行为型]观察者模式(Observer)
  6. hadoop3.1 分布式集群部署
  7. opencv mat
  8. C# T4使用
  9. 【互动问答分享】第7期决胜云计算大数据时代Spark亚太研究院公益大讲堂
  10. [centos6.5] yum makecache 连接错误的解决办法