2

Sorry for my bad english...

I have the most basic possible CodeIgniter setup and can't make it work... if i access the url http://domain.com/index.php?controllerX/method it works fine.

Now I want to be able to access http://domain.com/method

I configured on routes.php "controllerX" to be the default controller and try to use the follow .htaccess:

RewriteEngine on
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ /index.php/$1 [L]

I have tried multiple .htaccess and everytime the server just returns 403 errors. Even if my .htaccess contains only the first line "RewriteEngine on", it shows 403 errors. I have tried to set every folder to chmod 777 or 755 to test and this change nothing.

Is there a way to see what resource are giving the 403 error? Or am I comiting a mistake elsewhere?

Ok, i readed somewhere that I need "Options +FollowSymLink" on my htaccess ... with that the server show me 500 errors :(

EDIT Ok, now its working, with the follow htaccess:

Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ /index.php/$1 [L]
4

2 回答 2

0

将您的 .htaccess 文件更改为:

除了我们在 .htaccess 文件中所做的更改之外,我们还必须验证/更改以下设置:

Apache 读取位于 /var/www/html 目录下的 .htaccess 文件。您可以通过编辑 httpd.conf 文件来做到这一点:

须藤纳米 /etc/httpd/conf/httpd.conf

找到该部分并将 AllowOverride None 更改为

AllowOverride All

 <Directory /var/www/html>
    AllowOverride All
 </Directory>
Save and exit.

现在重新启动 Apache 以使更改生效:

sudo systemctl 重启 httpd

休息这对我有用

于 2018-02-21T11:49:04.163 回答
-1

我想你的问题也在这里得到了回答

RewriteEngine On
RewriteBase /

# 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.plugb.com/$1 [L,R=301]


RewriteBase /    
RewriteCond %{HTTP_HOST} !=""
RewriteRule ^index.php(/.*)?$ http://%{HTTP_HOST}$1 [R=301]
# 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]
于 2012-10-12T10:09:11.150 回答