我正在使用我的 Raspberry Pi 作為網路服務器,它的域是我在 Strato.de 上用 dyndns 購買的。我.htacces使用以下代碼附加了一個名為我的專案的檔案。
RewriteEngine on
RewriteCond %{THE_REQUEST} /([^.] )\.html [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]
我也試過這個:
RewriteCond %{REQUEST_URI} !(\.[^./] )$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule (.*) $1.html [L]
RewriteCond %{REQUEST_URI} !(\.[^./] )$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.htm -f
RewriteRule (.*) $1.htm [L]
RewriteCond %{REQUEST_URI} !(\.[^./] )$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule (.*) $1.php [L]
在 STRATO.de 的網站空間上托管我的網站之前,一切都適用于第一個版本,您可以在上面看到。但不僅僅是給我一個 404。

我只想從我的 URL 中洗掉結尾.html/.php和其他。
uj5u.com熱心網友回復:
- 登錄pi
sudo nano /etc/apache2/sites-enabled/000-default- 添加:
<Directory /var/www/html> Options Indexes FollowSymLinks MultiViews AllowOverride All # AllowOverride None Order allow,deny allow from all </Directory> sudo a2enmod rewritesudo /etc/init.d/apache2 restart oder service apache2 restart
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/363325.html
