需要 RewriteRule 方面的帮助 - Apache
这就是我想要做的:
http://www.mysite.com/ > http://www.mysite.com/index.php
http://www.mysite.com/asd > http://www.mysite.com/index.php?page=$1
asd
将是附加到 index.php 的 $page 变量的页面的名称。
我当前的重写规则成功重定向了请求的页面,但无法加载默认的index.php页面。
RewriteEngine On
RewriteRule ^([\w]*)$ /index.php?page=$1 [L]
我该如何解决这个问题? :/
Here's what I want to do:
http://www.mysite.com/ > http://www.mysite.com/index.php
http://www.mysite.com/asd > http://www.mysite.com/index.php?page=$1
asd
will be the name of the page(s) that get appended to index.php's $page variable.
My current rewrite rule successfully redirects the requested page but fails to load the default index.php page.
RewriteEngine On
RewriteRule ^([\w]*)$ /index.php?page=$1 [L]
How do I fix this? :/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要有一个仅匹配 /: 的规则
,然后是另一条规则:
You would need to have one rule that matches just the /:
And then your other one:
对于我的,我只是将整个路径传递到索引页。
然后使用
list()
和explode()
将其分块。否则,您将需要两条规则。
或者使用相同的规则并在 / 页面上有一个空的 ?page= 参数。
For mine, i simply pass the entire path to the index page.
Then use
list()
andexplode()
to chunk it up.Otherwise, you're going to need two rules.
Or use the same rule and on the / page have an empty ?page= parameter.