我整天都在努力,希望其他人可以帮忙。
我正在建立一个新站点(在我们的开发服务器上),并且在使用一些简单的SEO友好URL时遇到了麻烦。
我只是将一些SEO友好关键字重定向到静态PHP页面。我的文件可以在大多数链接上使用,但是2个由于未知原因而中断。
这是我的文件:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^about-us$ aboutus.php [L]
RewriteRule ^resource-center$ resourcecenter.php [L]
RewriteRule ^our-services$ ourservices.php [L]
RewriteRule ^management-solutions$ ms.php [L]
RewriteRule ^additional-services$ additionalservices.php [L]
RewriteRule ^contact-us$ contactus.php [L]
由于某种原因,资源中心和与我们联系将转到404页。当我单击链接时,会在“ contact-us”和“ resource-center”中添加一个斜杠,但不会在其他任何链接上添加。
如果我编辑htaccess文件并将^ resource-center $更改为^ resourcecenter $,它将可以正常工作。如果我将其更改为^ resource-center / $以说明添加了斜杠,则将加载页面,但不会加载CSS / JS / Images。
我在这里很困惑,尤其是因为它看起来如此不一致。所有文件都存在,没有会干扰的htaccess文件,HTML或htaccess中的所有链接都采用相同的格式,但是其中两个每次都给我错误。
如果有人可以帮助我,将不胜感激。
MultiViews
选项关闭试试这个代码:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /
RewriteRule ^about-us/?$ aboutus.php [L,NC]
RewriteRule ^resource-center/?$ resourcecenter.php [L,NC]
RewriteRule ^our-services/?$ ourservices.php [L,NC]
RewriteRule ^management-solutions/?$ ms.php [L,NC]
RewriteRule ^additional-services/?$ additionalservices.php [L,NC]
RewriteRule ^contact-us/?$ contactus.php [L,NC]
对于css / js等,您可以将其添加到页面的HTML标头中:
<base href="/" />
这样就可以/
从当前页面的URL而不是从当前页面的URL解析每个相对URL。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句