Apache .htaccess从地址隐藏问号
我做错了什么? 我有一个链接:Apache .htaccess从地址隐藏问号,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我做错了什么? 我有一个链接: 我需要在以下地址填写地址: eshop.mydomain.com/norma/something1/something2/something3/ 此地址: eshop.mydomain.com/norma-something 1-something 2-something 3.html 我唯一能做的就是 eshop.mydomain.com/?norma-something1-something2-something3.html 我需要隐藏问号,但我不知道如何:
我需要在以下地址填写地址:
eshop.mydomain.com/norma/something1/something2/something3/
此地址:
eshop.mydomain.com/norma-something 1-something 2-something 3.html
我唯一能做的就是eshop.mydomain.com/?norma-something1-something2-something3.html
我需要隐藏问号,但我不知道如何:(
这是我的.htaccess
#php_value memory_limit 256M
RewriteEngine On
RewriteBase /
RewriteRule /index.php / [R=301]
RewriteRule ^norma/([^/]+)/([^/]+)/([\d\.]+)$ %{DOCUMENT_ROOT}/index.php?$1-$2&-$3.html [L,QSA]
ErrorDocument 404 /doc/e404/
您正在重写规则中添加问号:
# right here -----------------------------------------------------------v
RewriteRule ^norma/([^/]+)/([^/]+)/([\d\.]+)$ %{DOCUMENT_ROOT}/index.php?$1-$2&-$3.html [L,QSA]
但我怀疑可能是一些因素导致了这种重定向的发生,而这种重定向实际上应该是服务器端的内部重写。请尝试将规则更改为:
RewriteEngine On
RewriteBase /
# this L is important ------------v
RewriteRule ^/?index.php / [R=301,L]
RewriteRule ^norma/([^/]+)/([^/]+)/([\d\.]+)$ /index.php?$1-$2&-$3.html [L,QSA]
如果我使用此选项,我的页面将抛出错误
永久移动
文档已移动到此。此外,在尝试使用ErrorDocument处理请求时遇到404 Not Found错误。
以下是代码:文档已移动到此处时,链接指向什么。
?文档已移动。请问哪里有问题?@LeníkRostík我不知道,您可以尝试删除RewriteRule^/?index.php/[R=301,L]
行,不确定你想用它做什么。你也可以像我在回答中所做的那样,从上一条规则中删除%{DOCUMENT\u ROOT}
。