我有一个PHP网站,有一些网页:虚拟目录htaccess以及URL重写
www.example.com/news
www.example.com/people
www.example.com/music
在每个页面是内容概述。例如,如果您点击www.example.com/news上的链接,则可以使用模板打开该网址的文章(www.example.com/article.php?url='example-of-article-url')
对于每个页面都需要重写。显示的网址应该是www.example.com/news/example-of-article-url ,这应该访问article.php文件。新闻目录是虚拟的。
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]
我一直在努力为:
RewriteRule ^news/(.*) article.php?url='$1' [R=301,L]
的www.example.com/news,www.example.com/people,www.example.com/music正在此代码重写
但是,当这加载,CSS和图像不是。生成的内容认为它位于/ news /目录中,因此无法找到其他文件。由于SEO原因,我无法使用规范网址。
是的,伟大的方法。这也起作用。 – Miguel