htaccess重写器在codeigniter中不起作用


htaccess rewriterule not working in codeigniter

在这里,我试图从我的代码点火器应用程序的URL中删除index.php。

为此,我写了这样的.htaccess文件:

# Turn on URL rewriting
RewriteEngine On
# Installation directory
# RewriteBase /projectname/
# Protect hidden files from being viewed
<Files .*>
    Order Deny,Allow
    Deny From All
</Files>
# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)'b.* index.php/$0 [L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php [PT]

它在xx.xx.xx.xxx服务器和mydomain.com中工作。在这里,我试图将相同的副本复制到另一个服务器yy.yy.yy.yyy。在这种情况下,重写URL不起作用。如果我使用'yy.yy.yy.yyy/index.php/login',则其工作正常。但是"yy.yy.yy.yyy/login",它抛出"在此服务器上找不到请求的URL/projectname/login"错误

对于您的主目录。htaccess尝试此操作,然后从config.php 中删除index.php

Options +FollowSymLinks
Options -Indexes
<FilesMatch "(?i)(('.tpl|'.ini|'.log|(?<!robots)'.txt))">
    Order deny,allow
    Deny from all
</FilesMatch>
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index'.php|images|robots'.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

不要触摸应用程序目录中的.htaccess文件。