【问题标题】:Create pretty url from plain html page?从普通的 html 页面创建漂亮的 url?
【发布时间】:2013-06-16 13:12:30
【问题描述】:

我查看了几篇关于设置“Pretty URL”的文章,但我似乎无法找到任何适合我的方法。我是整个 .htaccess 过程的新手,我所看到的一切似乎都是针对动态的、基于 .PHP 的网站。这是我希望看到的:

丑陋的网址:http://www.example.com/test.html
漂亮的网址:http://www.example.com/test/

它当前尝试在 .htaccess 文件中使用的是:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([a-z]+)$ $1.html

到目前为止,我没有运气。我没有在页面上使用任何形式的 .php - 这些是静态 .html 页面。任何帮助将不胜感激。谢谢!

【问题讨论】:

  • 感谢您的评论!我给了解决方案页面一个镜头(只是改变了这一行:
  • 感谢您的评论!我给了解决方案页面一个镜头(只是更改了这一行:RewriteRule ([^.]+)\.html quotist.com/$1/%1/%2? [L,R=301] 相同的 500 错误消息。这是我的新 .htaccess 代码我正在使用:Options +FollowSymLinks -MultiViews -Indexes RewriteEngine on RewriteBase / RewriteCond %{ENV:REDIRECT_STATUS} 200 RewriteRule ^ - [L] RewriteCond %{QUERY_STRING} ^(letter)=(\w)$ [NC] RewriteRule ([^ .]+)\.html igeniusstore.com/$1/%1/%2? [L,R=301] RewriteCond %{REQUEST_URI} ^/([\w-]+)/(字母)/\w/? [NC] RewriteRule ^ /%1 .html?%2=%3 [L,QSA]
  • 我什至尝试了这个基本代码,但仍然无法让它工作:RewriteEngine On RewriteRule ^this-test/?$ test.html [NC,L]

标签: .htaccess friendly-url clean-urls pretty-urls


【解决方案1】:

没关系。我弄清楚是什么问题。我的编译器损坏了 .htaccess 文件,该文件在加载时触发了站点范围的错误消息。你可以在这里看到它现在正在工作:

http://www.igeniusstore.com/this-test.html

http://www.igeniusstore.com/this-test

这是我使用的基本代码:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html

感谢您的所有帮助。干杯!

【讨论】:

    猜你喜欢
    • 2018-02-07
    • 2013-05-25
    • 1970-01-01
    • 2023-02-26
    • 2012-07-20
    • 2021-03-22
    • 1970-01-01
    • 2014-12-02
    • 1970-01-01
    相关资源
    最近更新 更多