从 CodeIgniter url 中删除索引.php将重定向到本地主机


Removing index.php from CodeIgniter url redirects to localhost

我正在使用WampServer进行开发,并试图从CodeIgniter网址中删除index.php。将这些行添加到 .htaccess 文件中,正如我在 ellislab 网站中看到的那样:https://www.codeigniter.com/user_guide/general/urls.html

RewriteEngine on
RewriteCond $1 !^(index'.php|images|robots'.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

这是我网站的根:http://localhost/job/

但是现在,当我想像 http://localhost/job/seeker 一样浏览网址时,我会看到 http://localhost/上的Wampserver配置页面。

我能做什么?

谢谢

RewriteEngine on
RewriteBase /job
RewriteCond $1 !^(index'.php|images|table-images|robots'.txt|styles|js|uploads)
RewriteRule ^(.*)$ index.php/$1 [L]

并在应用程序/配置/配置中设置.php

$config['base_url'] = 'http://127.0.0.1:8000/job/';
$config['index_page'] = 'index.php';

试试这个:

     RewriteEngine On
     RewriteBase /projects/hc/homecare/trunk/homecare 
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteCond $1 !^(index'.php|images|robots'.txt|css|docs|js|system)
     RewriteRule ^(.*)$ /projects/hc/homecare/trunk/homecare/index.php?/$1 [L]

以下代码取自 http://www.farinspace.com/codeigniter-htaccess-file/

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
### Canonicalize codeigniter URLs
# If your default controller is something other than
# "welcome" you should probably change this
RewriteRule ^(welcome(/index)?|index('.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
# Enforce www
# If you have subdomains, you can add them to 
# the list using the "|" (OR) regex operator
RewriteCond %{HTTP_HOST} !^(www|subdomain) [NC]
RewriteRule ^(.*)$ http://www.domain.tld/$1 [L,R=301]
# Enforce NO www
#RewriteCond %{HTTP_HOST} ^www [NC]
#RewriteRule ^(.*)$ http://domain.tld/$1 [L,R=301]
###
# Removes access to the system folder by users.
# Additionally this will allow you to create a System.php controller,
# previously this would not have been possible.
# 'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php

确保 .htaccess 文件的名称正确且与 index.php 文件位于同一目录中,并且mod_rewrite在服务器堆栈的 Apache 中启用。

还要确保根据同一链接再次正确设置代码点火器配置,编辑配置文件。

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

$config['index_page'] = "";

另外,请使用搜索。这个问题在很多地方都出现了很多,到处都有答案。

它发生在 wamp 服务器中试试这个

RewriteEngine On
RewriteBase /name_of_your_project
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index'.php|images|js|uploads|css|robots'.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
   **

删除索引.php并将 anyurl.com 重定向到编码器中的 www.anyurl.com

**

   RewriteEngine on
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule .* index.php/$1 [PT,L]
   RewriteCond %{HTTP_HOST} !^www'.
   RewriteCond %{HTTPS}s on(s)|offs()
   RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R]