I'm using my Raspberry Pi as an webserver with a domain that i bought on strato.de with a dyndns. I attached a file named .htacces
to my project with following code.
RewriteEngine on
RewriteCond %{THE_REQUEST} /([^.] )\.html [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]
I also tried this one:
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]
Before hosting my website on the webspace from STRATO.de everything worked with the first version, which you can see above. But not its only giving me an 404.
I just want to remove the ending .html
/.php
and other from my URL.
CodePudding user response:
- Log in into pi
sudo nano /etc/apache2/sites-enabled/000-default
- Add:
<Directory /var/www/html> Options Indexes FollowSymLinks MultiViews AllowOverride All # AllowOverride None Order allow,deny allow from all </Directory>
sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart oder service apache2 restart