我在用RewriteRules在.htaccess中重写目录中的一系列文件时遇到了困难。
我有index.php?page=page_name
到目前为止,这个已经开始工作了,而且我已经成功了。
#RewriteRule ^([A-Za-a0-9-]+)/?$ index.php?page=$1 [NC]
#RewriteRule ^([A-Za-a0-9-]+)/([0-9-]+)/([A-Za-a0-9-]+)?$ index.php?page=$1&id=$2&name=$3 [NC]我已经能够通过index.php文件链接视图,这是上面提到的视图。
我面临的挑战是链接public_html/view/css/style.css目录中的文件,使其看起来像public_html/css/style.css。
到目前为止,这是我一直在尝试的,但并不奏效:
#RewriteRule ^css/(.*)$ /view/css/$1 [NC,L]我有文件在:
view/css
view/js还有其他目录。我想让他们看起来像:
domain_name.com/css/style.css
domain_name.com/js/style.css请告诉我我做错了什么,为什么这不起作用。
发布于 2014-02-23 09:24:09
您可以在根.htaccess中使用此规则:
RewriteRule ^(js|css)/(.+)$ /view/$1/$2 [NC,L]发布于 2014-02-23 09:27:30
移除#符号;它将整行转换为注释,并意味着您的规则永远不会执行:
RewriteRule ^css/(.*)$ /view/css/$1 [NC,L]
RewriteRule ^js/(.*)$ /view/js/$1 [NC,L]https://stackoverflow.com/questions/21963642
复制相似问题