.htaccess を編集した後。css ファイルに到達できなくなりました。どうすればこの問題を解決できますか。
書き換えルールを無効にすると、問題なく動作しますが、URL バーに file.php?id=5&title=hello と入力しても、file.php?id/title にリダイレクトされないため、手動で入力すると、cssが削除されます
.htaccess コード:
RewriteEngine On
RewriteRule ^([0-9]+)/([a-zA-Z0-9_-]+)$ file.php?id=$1&title=$2
RewriteRule ^([0-9]+)/([a-zA-Z0-9_-]+)/$ file.php?id=$1&title=$2
私もこれを試しました:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)/([a-zA-Z0-9_-]+)$ file.php?id=$1&title=$2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)/([a-zA-Z0-9_-]+)/$ file.php?id=$1&title=$2
私もこれを試しました:
RewriteEngine On
RewriteCond $1 !^(jpg|jpeg|gif|ico|png|media|txt|xml|css|js)
RewriteRule ^([0-9]+)/([a-zA-Z0-9_-]+)$ file.php?id=$1&title=$2
RewriteRule ^([0-9]+)/([a-zA-Z0-9_-]+)/$ file.php?id=$1&title=$2
SQL インジェクションに対するセキュリティを強化するために、URL を非表示にしたいと考えています。
アップデート
これは動作中のバージョンです:
URL:http://localhost/21760
.htaccess ファイル:
RewriteEngine On
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^([0-9]+)$ file.php?id=$1&
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^([0-9]+)/$ file.php?id=$1
私はこれを使用しましたが、バックスラッシュなしで魅力的に機能します。
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)-watch-file-([0-9]+).html file.php?title=$1&id=$2