url 去除index.php的配置

PHP cooljun 2123℃ 0评论

1.nginx隐藏index.php

找到nginx的配置文件  使用下面代码替换

 

#listen       80;
#server_name 192.168.11.33;
#index index.html index.htm index.php;
#root  /home/wwwroot/; access_log  /home/wwwlogs/access.log  access;
location /cy {
    index  index.html index.php;
    try_files $uri $uri/ /cy/index.php?$args;
}

location ~ \.php {
    fastcgi_pass  unix:/tmp/php-cgi.sock;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_script_name;
}

2.window 隐藏index.php

  • 打开apache的配置文件,conf/httpd.conf
  • LoadModule rewrite_module modules/mod_rewrite.so,把该行前的#去掉。
  • 在文件最后加上下面代码
<Directory "D:/wamp/www/iterm">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
  • 在iterm项目文件夹里创建.htaccess 文件,文件内容如下
<IfModule rewrite_module>
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
</IfModule>

 

转载请注明:cooljun小窝 » url 去除index.php的配置

如果你觉得这篇文章对你有帮助,请支持我继续更新网站 !捐赠本站
喜欢 (0)or分享 (0)

您必须 登录 才能发表评论!