.htaccess mod rewrite htaccess显示链接

.htaccess mod rewrite htaccess显示链接,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我在浏览器中正确显示链接时遇到mod rewrite问题 我总是像这样在我的页面上放置链接 http://domain.com/contact-us.html 然后在我的.htaccess文件中使用它 Options FollowSymLinks RewriteEngine On RewriteRule ^([^.]+)\.html$ http://domain.com/index.php?h=$1 [L] 我请求index.php页面上的h变量获取并使用slug“contact u

我在浏览器中正确显示链接时遇到mod rewrite问题

我总是像这样在我的页面上放置链接

 http://domain.com/contact-us.html
然后在我的.htaccess文件中使用它

 Options FollowSymLinks
 RewriteEngine On
 RewriteRule ^([^.]+)\.html$ http://domain.com/index.php?h=$1 [L]
我请求index.php页面上的h变量获取并使用slug“contact us”

这一直运行良好,仍然会在浏览器中显示domain.com/contact-us.html


我在1和1上加载了一个站点,在浏览器中看到的不是domain.com/contact-us.html,而是domain.com?h=联系我们。除了没有正确显示链接之外,一切都正常

明白了,但对于那些将来可能有帮助的人来说。首先在每次测试中清除缓存

 Options FollowSymLinks
 RewriteEngine On
 RewriteRule ^([^.]+)\.html$ /index.php?h=$1 [L]
不要包含域。在我的例子中,该网站在public_html文件夹中上升了一级,所以我认为我必须包含该域

增加

非常好,最终代码

 Options FollowSymLinks
 RewriteEngine On
 RewriteBase /
 Options FollowSymLinks
 RewriteEngine On
 RewriteRule ^([^.]+)\.html$ /index.php?h=$1 [L]
RewriteBase /
 Options FollowSymLinks
 RewriteEngine On
 RewriteBase /
 Options FollowSymLinks
 RewriteEngine On
 RewriteRule ^([^.]+)\.html$ /index.php?h=$1 [L]