首页 > 解决方案 > 应用 .htaccess 后我的页面样式消失了

问题描述

美好的一天,我完成了一个项目,我正在尝试重写我尝试过的 url(静态和动态)

RewriteEngine on
RewriteRule ^home index.php [L]
RewriteRule ^contact contact-us.php  [L]
RewriteRule ^blog blog.php [L]

他们都运作良好。直到我在看起来像这样的动态 url 上尝试了同样的事情。

RewriteRule ^category/([0-9]+) single-mp3.php?uid=$1 [L]

在尝试了上述方法之后,它起作用了,但我的造型消失了。我也试过。

RewriteRule ^[a-zA-Z]+/([0-9]+)/?$ single-mp3.php?uid=$1 [L]

然而它并没有解决我的问题请帮帮我

标签: php.htaccess

解决方案


认为这就是你所追求的:

RewriteEngine on
RewriteRule ^home index.php [L]
RewriteRule ^contact contact-us.php  [L]
RewriteRule ^blog blog.php [L]
RewriteRule ^category/(.*)$ single-mp3.php?uid=$1 [L]

结果是:

curl 'http://localhost/home?query='
=> index
curl 'http://localhost/contact?query='
=> contact
curl 'http://localhost/blog?query='
=> blog
curl 'http://localhost/category/someid'
=> Array
(
    [uid] => someid
)
curl 'http://localhost/css/bootstrap.css'
=> css

推荐阅读