在我的网址中添加尾部斜杠
I have a serious problem since two days trying to rewrite the urls of my php website with htaccess.
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]
But what I expect for example, is to have http://www.example.com/services/
.
With the code, when I type that URL into the browsers address bar, I have a web page without CSS.
我有一个严重的问题,因为两天试图用htaccess重写我的php网站的网址。 p>
选项+ FollowSymlinks
RewriteEngine On
RewriteRule devis demande-devis.php
RewriteRule mentions-legales mentions-legales.php
RewriteRule condition-utilization 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]
code> pre>
但我所期望的是, http://www.example.com/services/ code >。 p>
使用代码,当我在浏览器地址栏中输入该URL时,我有一个没有CSS的网页。 p>
div >
Most likely the problem is relative versus absolute notation of the css file urls. Consult the http servers error log to see what is actually referenced or check the delivered html source of the page that lacks the style definitions.
The page you specify in your comment to the question shows both, relative and absolute references of css files. However you have no rewriting rules for those...
That works as usual. Just ensure you set the right link to your CSS files so that the browser is able to request them without 404's from your server.
As you have probably edited the URLs within the .htaccess files after you've written the php script, you need to reflect these changes in your PHP script, too, by updting the links in there, too.
Monitor your server error log to find out which URIs are wrongly send.
Review those.
Then improve the output of your application by fixing that erroneous output.
Please see as well:
and similar questions that are about the root of your problem.