本文介绍了.htaccess rewriteRule(./index.php?page=projects&id=$1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用htaccess重写URL,但是我有一些问题希望能对我有所帮助。
I'm trying to rewrite the URL using htaccess, but I have some problems that I hope you could help me with.
这是我的内容。 htaccess文件
This is the contents of my .htaccess file
RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^(.*)$ ./index.php?page=projects&id=$1以下规则非常有效,它可以转换以下网址:
The following rule works great, it converts this url:
peterboruplund.dk/?page=projects&id=projectname为此
peterboruplund.dk/projectname问题是我还希望只能查看一个页面。就像我写这个网址一样:
But the problem is that I also want to be able to only view a page. Like if I write this url:
peterboruplund.dk/?page=info它应该转到名为信息的页面,如下所示:
It should go to the page called "info", like this:
peterboruplund.dk/info我的问题是我如何才能同时达到这两个目标
My problem is how can I achieve both things at the same time?
最好,彼得
推荐答案/ info 的另一条规则:
RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^([^/]+)/?$ ?page=$1 [L,QSA,NC] RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^(.+)$ index.php?page=projects&id=$1 [L,QSA]更多推荐
.htaccess rewriteRule(./index.php?page=projects&id=$1)
发布评论