.htaccess ModReWrite 帮助
我的重写代码遇到一些问题。 请注意, .htaccess 文件位于子域文件夹中 (...public_html/subdomain/ )
我只是想重写一个页面请求:
http://subdomain.mysite.com/home
http://subdomain.mysite.com/index.php?page=home
我的 .htaccess 文件看起来像这样...
RewriteEngine On
RewriteRule ^/([A-Za-z0-9\-\_])$ /index.php?page=$1
您有什么想法吗?
I am having some trouble with my ReWrite code. Please note that the .htaccess file is in the subdomain folder (...public_html/subdomain/ )
I am simply trying to rewrite a page request:
http://subdomain.mysite.com/home
http://subdomain.mysite.com/index.php?page=home
My .htaccess file looks like this...
RewriteEngine On
RewriteRule ^/([A-Za-z0-9\-\_])$ /index.php?page=$1
Does anything jump out at you?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您当前的规则可能适用于一个字符长的网址(斜线之后)!
添加
+
表示一个或多个字符,或添加*
表示零个或多个字符
Your current rule probably works for urls one character long (after the slash)!
Add a
+
to signify one or more characters, or a*
for zero or moreTry
如果要在 .htaccess 文件中使用规则,则需要从
RewriteRule
模式中去除上下文每个目录路径前缀。 如果 .htaccess 文件位于文档根/
中,则需要去掉前导/
。此外,您还需要量化字符集。 否则它只会描述一个字符。
所以尝试这个规则:
If you want to use the rules in a .htaccess file, you need to strip the contextual per-directory path prefix from the
RewriteRule
pattern. If the .htaccess file is located in the document root/
, you need to strip the leading/
.Additionally you need to quantify the character set. Otherwise it would only describe one character.
So try this rule:
我认为
还可以;)
I think
is ok ;)