【问题标题】:how to create .htaccess file to recreate a frindly URL如何创建 .htaccess 文件以创建友好的 URL
【发布时间】:2015-03-13 20:23:50
【问题描述】:

我有这个网址:

localhost/prefinal/profile.php?username=Admin

并且想要成功:

localhost/prefinal/profile/Admin

我使用 .htaccess 文件并设置以下规则:

RewriteRule ^profile/([^/]*)$ /prefinal/profile.php?username=$1 [L]

页面工作正常..但 CSS 无法在其中工作:

not work css

应该是:

work css

谢谢

【问题讨论】:

  • 您需要在 html 的标题中添加 base href='' ..

标签: php css .htaccess url mod-rewrite


【解决方案1】:

您的 HTML sours 看起来如何(link 标记到样式表)? 我猜你应该在 before RewriteRule

添加几行
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^profile/([^/]*)$ /prefinal/profile.php?username=$1 [L]

【讨论】:

  • 这是 PHP 而不是 html 这是我的样式表链接:
猜你喜欢
  • 2011-03-03
  • 2014-06-20
  • 2015-04-08
  • 2014-12-04
  • 1970-01-01
  • 2011-12-24
  • 1970-01-01
  • 2015-11-03
  • 2017-11-08
相关资源
最近更新 更多