1、2 日経っても、まだ Mod Rewrite と戦っています。私の開発時間の 60% はサーバーとの戦いに費やされているようです。
私の現在の URL 構造は、すべてのhttp://example.com/xyzとhttp://example.com/xyz/abcが index.php によって処理されるようになっています。問題は、http://example.com/admin/セクションがあることです。これは、HTTP 要求を介してアクセスできるようにする必要がある実際のディレクトリです (CMS ディレクトリです)。
CMS http://example.com/admin/を参照しようとすると、URL がhttp://example.com/admin/?n=adminに変更され、404 が返されます。 =admin 引数として。
私が理解できないのは、これらの 2 つの条件が無視されている理由です。
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !^admin(?:\/)?$
そして、なぜ http://example.com/admin/?n=admin にリダイレクトされるのですか(単にhttp://example.com/admin/で停止するのではなく.
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !^admin(?:\/)?$
# allow access to certain subdirectories.
RewriteRule ^admin(?:\/)?$ /admin/ [L,NC]
# redirect all old URLs to new pages (or 404 sitemap page if no analog?).
RewriteRule ^company/about(?:\/)?$ /company [R=301,L,NC]
# catch any others and try to serve them right
RewriteRule ^/?(.+).html$ /$1 [R=301,L]
RewriteRule ^/?([0-9]+)(?:\/)?$ /index.php?p=$1 [L]
RewriteRule ^/?([-a-zA-Z0-9_+]+)(?:\/)?$ /index.php?n=$1 [L]
RewriteRule ^/?([-a-zA-Z0-9_+]+)/([-a-zA-Z0-9_+]+)(?:\/)?$ /index.php?n=$2 [L]
誰かアイデアを提供したり、.htaccess の欠陥を指摘したりできますか?