htaccess的重定向。html的非html的不工作 [英] .htaccess redirect .html to non .html not working
问题描述
使用我的.htaccess这样的:
的RewriteCond%{THE_REQUEST} \ html的
重写规则^(。*)\。HTML / $ 1 [R = 301,L]
但是,该网站显示的是一个404未找到,即使我有这个文件。
该文件是ishared.html。重定向的工作原理,但它需要一个没有找到,如果你去 http://headupshouldersback.com/ishared.html
任何提示?谢谢!
编辑:下面给了我500服务器错误在我的网站:
的RewriteCond%{THE_REQUEST} \ html的
重写规则^(。*)\。HTML / $ 1 [R = 301,L]
重写规则^(。*)/$1.html [QSA,L]
您重定向后:
的RewriteCond%{THE_REQUEST} \ html的
重写规则^(。*)\。HTML / $ 1 [R = 301,L]
...添加到下一行:
重写规则^(。*)/index.php?page=$1.html [QSA,L]
这是去工作。这将显示的 ishared.html
的内容,如果你做的请求 ishared
。
编辑:
它钻进了一个循环,对不起,你需要使用一些PHP的code。
的index.php:
< PHP的file_get_contents((使用isset($ _ GET ['页']))$ _GET ['页']:?的error.html)?; ?>
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]
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"); ?>
这篇关于htaccess的重定向。html的非html的不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!