在我的url中添加尾部斜杠


add trailing slash to my urls

自从两天试图用htaccess重写php网站的url以来,我遇到了一个严重的问题。

Options +FollowSymlinks
RewriteEngine On
RewriteRule devis demande-devis.php
RewriteRule mentions-legales mentions-legales.php
RewriteRule condition-utilisation condition-utilisation.php
RewriteRule condition-generales-ventes condition-generales-ventes.php
RewriteRule fournisseur fournisseur.php
RewriteRule qui-sommes-nous qui-sommes-nous.php
RewriteRule faq faq.php
RewriteRule services services.php
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !example.php
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [L,R=301]

但例如,我所期望的是http://www.example.com/services/

有了代码,当我在浏览器地址栏中键入URL时,我就得到了一个没有CSS的网页。

问题很可能是css文件url的相对表示法与绝对表示法。查阅http服务器错误日志以查看实际引用的内容,或者检查缺少样式定义的页面的已交付html源。

您在问题注释中指定的页面同时显示css文件的相对引用和绝对引用。然而,你没有改写规则。。。

一切如常。只需确保您为CSS文件设置了正确的链接,这样浏览器就可以在没有404的情况下从服务器请求它们。

由于您可能在编写php脚本后编辑了.htaccess文件中的URL,因此您也需要通过更新其中的链接来在php脚本中反映这些更改。

监视服务器错误日志,找出错误发送的URI。

回顾这些。

然后通过修复错误的输出来改进应用程序的输出。

也请参阅:

  • 自己动手通用页眉/页脚.php

以及关于你问题根源的类似问题。