Table of Contents
您可能感兴趣的文章
Home php教程 php手册 如何去除codeIgniter开发的网站url里面的index.php字符串

如何去除codeIgniter开发的网站url里面的index.php字符串

Jun 13, 2016 am 09:36 AM
codeigniter index.php url remove

使用codeIgniter(简称CI)做网站的朋友应该都会发现网站的任何url默认都会带个index.php,这个从SEO的角度上来说,对网站的影响是不大的,但是url的美观上来说,这个是非常让人不舒服的,下面我们就来看看如何去除使用codeIgniter开发的网站的url里面的index.php这几个字符吧。

做以下操作之前请确定你网站所运行的环境支持使用 .htaccess 进行url重写,如果可以的话,请继续往下看:

在网站根目录新建一个 .htaccess 文件,输入如下内容:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(index\\.php|images|css|js|robots\\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Copy after login

上面的代码第四行的意思是排除某些目录或文件,使得这些目录不会 rewrite 到 index.php 上,这一般用在图片、js、css 等外部资源上。也就是说非 PHP 代码都要排除出去。(这里我排除了 images 目录 css 目录 js 目录 以及 robots.txt 文件,当然 index.php 也应该被排除)

然后找到application/config/config.php文件,将:

$config['index_page'] = "index.php";
Copy after login

改为

$config['index_page'] = "";
Copy after login

您可能感兴趣的文章

  • 如何去除dedeCMS后台登陆页面的广告
  • thinkphp 如何去除url中的index.php
  • 如何优化网站页面提高网页的加载速度
  • JavaScript去除字符串空格方法完美总结
  • thinkphp截取中文字符串的方法
  • 肩,背部肌群锻炼-引体向上-俯立划船-俯卧挺身-站姿负重俯身弯起-坐姿颈后下拉-俯立正握上拉-颈前宽握引体向上
  • php bom去除工具,php批量去除bom的代码
  • Mysql查询带单引号字符串及插入带单引号字符串需要注意问题
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to get rid of arrow icons for shortcuts on Windows 11 How to get rid of arrow icons for shortcuts on Windows 11 Dec 28, 2023 am 10:39 AM

After many users use the latest win11 system, a small arrow appears on the shortcut icon on the desktop, which affects the appearance. Therefore, we have brought you a tutorial to remove the small arrow from the win11 shortcut icon. If you also think it does not look good, come and watch it. Let’s see how it works. How to remove the small shortcut arrow in win11: 1. First, press the "win+r" shortcut keys on the keyboard at the same time. 2. Then open "Run", enter the "regedit" command, and click the "OK" button. 3. Next, enter the "Registry Editor" page and click to open: HKEY_CLASSES_ROOT\lnkfile (can be copied and pasted). 4. After re-entering, right-click "lsShortcut" and select

How to remove watermark with Scanner How to remove watermark with Scanner Mar 05, 2024 pm 05:34 PM

Removing watermarks is a useful tool in the software Scanner. Some users are not sure how to remove watermarks in Scanner. You can click Remove Watermark in Edit PDF on the save interface to close it. Next, the editor will explain Users brought us an introduction to how to remove watermarks. If you are interested, come and take a look! Scanner King usage tutorial How to remove the watermark with Scanner King? Answer: You can click on the save interface to edit the watermark removal in the PDF. Details: 1. Enter the software and click the [Camera] icon. 2. Photograph and scan the documents that need to be watermarked. 3. Click [→] to proceed to the next step. 4. After completing editing, click [✓]. 5. Click [Edit PDF]. 6. Select [Remove Watermark] below.

PHP function introduction—get_headers(): Get the response header information of the URL PHP function introduction—get_headers(): Get the response header information of the URL Jul 25, 2023 am 09:05 AM

PHP function introduction—get_headers(): Overview of obtaining the response header information of the URL: In PHP development, we often need to obtain the response header information of the web page or remote resource. The PHP function get_headers() can easily obtain the response header information of the target URL and return it in the form of an array. This article will introduce the usage of get_headers() function and provide some related code examples. Usage of get_headers() function: get_header

How to remove shortcut arrow in win11 How to remove shortcut arrow in win11 Jul 05, 2023 pm 02:17 PM

How to remove shortcut arrow in win11? Many Win11 users have created shortcut icons on the system desktop, but there is a small arrow-like symbol on the shortcut icon, which makes the overall icon look very ugly. So is there any corresponding method to remove the small arrow on the Windows 11 system shortcut icon? Many friends don’t know how to operate in detail. The editor below has compiled a tutorial on clearing the small arrow shortcuts on the desktop in Win11. If you are interested, follow the editor and read on! Tutorial on clearing the small arrow shortcuts on the desktop in win11 1. Open the menu bar and find Run or just win+R. 2. Enter regedit and click OK. 3. Locate HKEY_CLASSES_

Why NameResolutionError(self.host, self, e) from e and how to solve it Why NameResolutionError(self.host, self, e) from e and how to solve it Mar 01, 2024 pm 01:20 PM

The reason for the error is NameResolutionError(self.host,self,e)frome, which is an exception type in the urllib3 library. The reason for this error is that DNS resolution failed, that is, the host name or IP address attempted to be resolved cannot be found. This may be caused by the entered URL address being incorrect or the DNS server being temporarily unavailable. How to solve this error There may be several ways to solve this error: Check whether the entered URL address is correct and make sure it is accessible Make sure the DNS server is available, you can try using the "ping" command on the command line to test whether the DNS server is available Try accessing the website using the IP address instead of the hostname if behind a proxy

How to remove mosaic How to remove mosaic How to remove mosaic How to remove mosaic Feb 22, 2024 pm 03:22 PM

Use the imitation stamp to pick up the color of the picture and then apply it. Tutorial Applicable Model: Lenovo AIO520C System: Windows 10 Professional Edition: Photoshop 2020 Analysis 1 First enter PhotoShop and open the mosaic picture. 2In the toolbar on the left, find and click Clone Stamp. 3 Then press and hold the Alt key on the keyboard. 4. Move the mouse to pick the color in the picture. 5Then release the Alt key on the keyboard. 6Finally, use the mouse to smear on the mosaic area to eliminate the mosaic. Supplement: What is the principle of mosaic removal? 1. If you want to remove mosaic from a picture, it is equivalent to painting on a canvas with an outline. Although the color aspect is easier to handle, it is still very difficult to complete. because

What is the difference between html and url What is the difference between html and url Mar 06, 2024 pm 03:06 PM

Differences: 1. Different definitions, url is a uniform resource locator, and html is a hypertext markup language; 2. There can be many urls in an html, but only one html page can exist in a url; 3. html refers to is a web page, and url refers to the website address.

How to implement custom middleware in CodeIgniter How to implement custom middleware in CodeIgniter Jul 29, 2023 am 10:53 AM

How to implement custom middleware in CodeIgniter Introduction: In modern web development, middleware plays a vital role in applications. They can be used to perform some shared processing logic before or after the request reaches the controller. CodeIgniter, as a popular PHP framework, also supports the use of middleware. This article will introduce how to implement custom middleware in CodeIgniter and provide a simple code example. Middleware overview: Middleware is a kind of request

See all articles