ThinkPHP去掉URL中的index.php

1,先确认你有没mod_rewrite.so模块

/usr/lib/apache2/modules/mod_rewrite.so

然后在httpd.conf最后一行加上(我不加也行,自己都奇怪)

LoadModule rewrite_module modules/mod_rewrite.so

重启
/etc/init.d/apache2 restart

2,将/etc/apache2/sites-enabled/000-default中的

AllowOverride None 将None改为 All

3,将TP的conf配置文件里写 ‘URL_MODEL‘ => ‘2‘(开启REWRITE模式)

4,.htaccess文件必须放到项目根目录下,在文件里面添加

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

  最后重启apache即可

时间: 2024-08-06 07:29:17

ThinkPHP去掉URL中的index.php的相关文章

thinkphp 去掉URL 里面的index.php(?s=)

例如你的原路径是 http://localhost/test/index.php/home/goods/index.html 那么现在的地址是 http://localhost/test/home/goods/index.html 如何去掉index.php呢?1.httpd.conf配置文件中加载了mod_rewrite.so模块  //在APACHE里面去配置 #LoadModule rewrite_module modules/mod_rewrite.so把前面的警号去掉 2.AllowO

thinkphp 去掉URL 里面的index.php

例如你的原路径是 http://localhost/test/index.php/home/goods/index.html 那么现在的地址是 http://localhost/test/home/goods/index.html 如何去掉index.php呢? 1.httpd.conf配置文件中加载了mod_rewrite.so模块  //在APACHE里面去配置 #LoadModule rewrite_module modules/mod_rewrite.so把前面的警号去掉 2.Allow

nginx去掉url中的index.php

使用情境:我想输入www.abc.com/a/1后,跳转到www.abc.com/index.php/a/1 配置Nginx.conf在你的虚拟主机下添加:  location / {      if (!-e $request_filename){           rewrite ^/(.*)$ /index.php/$1 last;      } } 如果你的项目入口文件在一个子目录内,则: location /目录/ {      if (!-e $request_filename){

ThinkPHP 隐藏URL中的 index.php

去掉 URL 中的 index.php 通常的URL里面含有index.php,为了达到更好的SEO效果可能需要去掉URL里面的index.php ,通过URL重写的方式可以达到这种效果,通常需要服务器开启URL_REWRITE模块才能支持. 例如原来的 URL 为: http://127.0.0.1/index.php/Index/insert 去掉 index.php 之后变为: http://127.0.0.1/Index/insert 第一步:更改Apache的httpd.conf 配置

PHP CI(CodeIgniter) 如何去掉url中的index.php

1.打开Apache配置文件httpd.conf,找到 1 #LoadModule rewrite_module modules/mod_rewrite.so 去掉前面的# 搜索AllowOverride,将相应Directory下的AllowOverride设置为All 1 AllowOverride All 2.在CI的根目录下,建立.htaccess文件,文件内容如下 1 RewriteEngine On 2 3 RewriteCond %{REQUEST_URI} ^system.* 4

thinkphp框架url中隐藏index.php

1.httpd.conf配置文件中加载了mod_rewrite.so模块 //在APACHE里面去配置 #LoadModule rewrite_module modules/mod_rewrite.so把前面的警号去掉 2.在apache配置文件httpd.conf中,将里面的AllowOverride None都改为AllowOverride All 进行1和2之后,一定要重启apache服务 3..htaccess文件必须放到根目录下 (windows里面创建.htaccess,新建任何一个

去掉 url 中的 index.php

Apache服务器则开启 mod_rewrite 模块 在 Aoache 配置文件 httpd.conf 中查找  LoadModule rewrite_module modules/mod_rewrite.so  去掉前面 '#' 则为开启 在跟目录创建 .htaccess 文件  内容如下 RewriteEngine On     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     R

ThinkPHP去除url中的index.php

例如你的原路径是 http://localhost/app/index.php/module/action/var/value/那么现在的地址是 http://localhost/app/module/action/var/value/ 去除index.php 1.httpd.conf配置文件中加载了mod_rewrite.so模块  //在APACHE里面去配置 #LoadModule rewrite_module modules/mod_rewrite.so把前面的警号去掉 2.AllowO

nginx服务器怎样去掉url中的index.php

server { listen 80; server_name yourdomain.com; root /home/yourdomain/www/; index index.html index.htm index.php; if (!-e $request_filename) { rewrite ^(.*)$ /index.php$1 last; } location ~ .*\.php(\/.*)*$ { include fastcgi.conf; fastcgi_pass 127.0.0