重新路由所有请求到index.php与要求作为查询字符串(的.htaccess) [英] Re-route all requests to index.php with request as query string (.htaccess)
问题描述
我在写我的第一个.htaccess文件,虽然我已经学到了很多东西已经我有一件事,我挣扎着。
I'm writing my very first .htaccess file and although I've learnt a lot already I have one thing that I'm struggling with.
我有一个CMS生成基于一个名为文件名这是通过我的网址,例如通过可变的网页...的index.php?文件名= about.htm中
I have a CMS that generates pages based upon a variable called "filename" that's passed through my URL for example... index.php?filename=about.htm
所以,我只有一个真正的文件...的index.php
So I only have one real file... index.php
我想的index.php?文件名无法显示,因此所有的URL看起来像正常即使文件名查询字符串仍在通过www.example.com/about.htm。
I would like "index.php?filename" to not appear so all URL's look normal like www.example.com/about.htm even though the "filename" query string is still being passed.
我希望我所做的意识,这是可能的......谢谢你们!
I hope I've made sense and this is possible... Thanks guys!
推荐答案
要重写 / $ VAR
到 /index.php?filename= $ VAR
?尝试粘贴到的.htaccess
文件:
Want to rewrite /$var
to /index.php?filename=$var
? Try to paste this into the .htaccess
file:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/index\.php$
RewriteCond %{QUERY_STRING} filename=([a-z0-9-_])
RewriteRule ^(.*) /index.php?filename=%1
这篇关于重新路由所有请求到index.php与要求作为查询字符串(的.htaccess)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!