问题
using this in my .htaccess:
RewriteCond %{THE_REQUEST} \.html
RewriteRule ^(.*)\.html$ /$1 [R=301,L]
But the site is displaying a 404 Not Found, even though I have the file.
The file is ishared.html. The redirect works, but it takes to a not found, if you go to http://headupshouldersback.com/ishared.html
Any tips? Thanks!
EDIT: The following gave me 500 server error on my site:
RewriteCond %{THE_REQUEST} \.html
RewriteRule ^(.*)\.html$ /$1 [R=301,L]
RewriteRule ^(.*) /$1.html [QSA,L]
回答1:
After your redirection:
RewriteCond %{THE_REQUEST} \.html
RewriteRule ^(.*)\.html$ /$1 [R=301,L]
Add to the next line:
RewriteRule ^(.*) /index.php?page=$1.html [QSA,L]
It is going to work. This will show the contents of ishared.html
if you do the request for ishared
.
EDIT:
It got into a loop, sorry, you need to use some php code.
index.php:
<?php file_get_contents( (isset($_GET['page'])) ? $_GET['page'] : "error.html"); ?>
来源:https://stackoverflow.com/questions/24294308/htaccess-redirect-html-to-non-html-not-working