2

我正在使用代码点火器。我有前端应用程序和后端应用程序,例如

/系统/

/应用/

   /front/

   /admin/

index.php

admin.php

.htaccess

我想要我的网址,例如http://example.com/news/article1(对于网站) http://example.com/news/admin(对于管理员)

在 .htaccess 我写过

RewriteEngine On
# If the user types just "admin".
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/admin$ admin\.php [L,QSA]

# If the user enter in any admin section, like "admin/section".
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/admin\/(.*)$ admin\.php/$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d    
RewriteRule ^(.*)$ index.php?/$1 [L]

前端工作正常,但是当我输入 mydomain.com/admin 时,它会抛出 404 not found 错误。请帮我。

谢谢并恭祝安康

4

1 回答 1

1

我对 .htaccess 不是很好,但是从CI 网站,您可以将它用于您的 .htaccess 规则

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

然后使用路由重写您的网址。比尝试在 .htaccess 文件中执行此操作要容易得多

于 2012-08-22T16:22:04.160 回答