繁体   English   中英

从CodeIgniter网址中删除index.php重定向到本地主机

[英]Removing index.php from CodeIgniter url redirects to localhost

我正在使用WampServer进行开发,并尝试从CodeIgniter网址中删除index.php。 正如我在ellislab网站上看到的那样,将这些行添加到了.htaccess文件中: 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]

并在application / config / config.php中设置

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

以下代码摘自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文件位于同一目录中,并且在服务器堆栈上的Apache中启用了mod_rewrite。

还请确保您再次正确设置您的Code Igniter配置,根据同一链接,编辑您的配置文件。

$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]

尝试这个:

     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]
   **

删除index.php并在codeigniter中将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] 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM