0

私は Codeigniter に基づいたサイトを持っており、デフォルトのディレクトリ www.removed.com にいるときは問題ありません。ここにアクセスすると: www.removed.com/ 正常に動作します。

問題は、/admin フォルダー (実際には application/controllers/admin/dashboard.php..... に移動するときです) は、ルート構成で正しくルーティングされます。

管理者の下にあるもの (removed.com/admin/users/ など) の最後に末尾のスラッシュを追加すると、サイト全体が壊れて、URL がルートに関連する URL を挿入しようとします: http://www.removed.com /home/アカウント名/public_html/skc/admin/users

何か案は?

これが私の.htaccessです

<IfModule mod_rewrite.c>

RewriteEngine On

### 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\.removed\.com [NC]
# RewriteRule (.*) http://removed.com/$1 [R=301,L]

###

# 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} ^ci.*
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]

</IfModule>


<IfModule !mod_rewrite.c>

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

</IfModule>

ルート構成は次のとおりです(要求どおり):

$route['default_controller'] = "main";
$route['404_override'] = '';
$route['about'] = "main/about";
$route['news'] = "main/news";
$route['bikes'] = "main/bikes";
$route['gallery'] = "main/gallery";
$route['contact'] = "main/contact";

$route['admin'] = "admin/dashboard";
$route['admin/login'] = "admin/dashboard/login";
$route['admin/logout'] = "admin/dashboard/logout";
$route['admin/users/view-user'] = "admin/users/view_user";
$route['admin/users/view-user/:num'] = "admin/users/view_user";
4

1 に答える 1

1

Change this condition to exclude the admin directory:

RewriteCond %{REQUEST_URI} ^ci.*

Additionally, you're currently using a blacklist approach here, where a whitelist one would be more effective. So, if you for example have all your images, css and javascript files in an 'assets' directory, if we assume that this is everything that needs to be accessible from the outside world, you should do this:

RewriteCond %{REQUEST_URI} !^(index\.php|assets\/.*\..*)
于 2012-11-13T13:09:40.720 に答える