PHP网站转换为静态HTML网站 - 链接问题 [英] PHP Website Converted to Static HTML site - Linking Issue

查看:171
本文介绍了PHP网站转换为静态HTML网站 - 链接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个动态PHP网站,我需要转换成一个静态网站给客户端。我使用 wget 来拉取文件,它完全符合我的需要。唯一的问题是...之前的链接(在google中索引的)没有文件扩展名。我使用.htaccess来摆脱.php文件扩展名。



所以我的一个URL将如下所示:
http:// www.domain.com/about /



当我收到一个静态版本的网站时,它将所有链接更改为.html



这可以很好,因为我可以使用htaccess来摆脱该文件扩展名,因此我的所有链接将与以前一样。那么,每个页面中的所有内部链接都链接到.html版本。



有没有一种方法可以让htaccess指导用户,如果他们去.html它会带他们关于没有扩展?所以我所有的内部链接仍然可以工作?



或者你们有什么其他建议可以解决这个问题吗?



这是我使用的wget代码:

  wget -k -K -E  - r -l 10 -p -N -F -nH http://www.domain.com/ 

如何得到它输出.php文件而不是.html?



谢谢!

解决方案

您可以将其添加到.htaccess中:

  RewriteRule ^([^ \。] +)$ $ 1.html [NC,L] 

取自: http://www.sicanstudios.com/how-to-remove-php -html-htm-extensions-with-htaccess /


I had a Dynamic PHP website which I needed to convert into a static website to give to a client. I used wget to pull the files and it did exactly what I needed. The only problem is..my links before (the ones indexed in google) have no file extension. I used .htaccess to get rid of the .php file extension.

So one of my URL's would look like this: http://www.domain.com/about/

When I got a static version of the website, it changed all of my links to .html

That could be fine, as I could use htaccess to get rid of that file extension and so all of my links will be the same as before. Well, all of the internal linking in each page is linking to the .html version.

Is there a way with htaccess to direct users if they go to about.html it will take them to about with no extension? So all of my internal linking will still work?

Or is there any other suggestions you guys might have on how to handle this?

Here is the wget code I use:

wget -k -K  -E -r -l 10 -p -N -F -nH http://www.domain.com/

How can I get that to output .php files instead of .html?

Thanks!

解决方案

You can add this to your .htaccess:

RewriteRule ^([^\.]+)$ $1.html [NC,L]

taken from: http://www.sicanstudios.com/how-to-remove-php-html-htm-extensions-with-htaccess/

这篇关于PHP网站转换为静态HTML网站 - 链接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆