1

目前

如果我添加这样的href,它已经可以工作了

<a href="central-cliente">Click here to go to the client center</a>

但是我的大多数链接都是这样的,它在 URL 中显示 clientarea.php - 应该覆盖它并成为中心客户端,如 .htaccess 中设置的那样

<a href="clientarea.php">Click here to go to the client center</a>

问题

我希望客户即使点击不友好的 url(.php、.html 等)也能看到友好的 url

.htaccess

Options +FollowSymlinks
RewriteEngine On
Options -MultiViews
RewriteBase /painel/

RewriteRule ^central-cliente$ ./clientarea.php [L,NC]
RewriteRule ^registro$ ./register.php [L,NC]
RewriteRule ^entrar$ ./clientarea.php [L,NC]
RewriteRule ^sair$ ./logout.php [L,NC]
RewriteRule ^whois-dominio$ ./domainchecker.php [L,NC]
RewriteRule ^pagina-inicial$ ./index.php [L,NC]
RewriteRule ^sua-conta$ ./clientarea.php [L,NC]
RewriteRule ^base-conhecimento$ ./knowledgebase.php [L,NC]
RewriteRule ^tickets-suporte$ ./submitticket.php [L,NC]
RewriteRule ^status-servidor$ ./serverstatus.php [L,NC]
RewriteRule ^recuperar-senha$ ./pwreset.php [L,NC]
RewriteRule ^status-servidor$ ./serverstatus.php [L,NC]
RewriteRule ^tickets-suporte-geral$ ./submitticket.php?step=2&deptid=1 [L,NC]
RewriteRule ^central-cliente$ ./clientportal.php [L,NC]
RewriteRule ^meus-dados$ ./clientarea.php?action=details [L,NC]
RewriteRule ^meus-servicos$ ./clientarea.php?action=products [L,NC]
RewriteRule ^meus-dominios$ ./clientarea.php?action=domains [L,NC]
RewriteRule ^meus-orcamentos$ ./clientarea.php?action=quotes [L,NC]
RewriteRule ^minhas-faturas$ ./clientarea.php?action=invoices [L,NC]
RewriteRule ^meus-tickets$ ./supporttickets.php [L,NC]
RewriteRule ^afiliados$ ./affiliates.php [L,NC]
RewriteRule ^meus-emails$ ./clientarea.php?action=emails [L,NC]
RewriteRule ^sair$ ./logout.php [L,NC]
RewriteRule ^enviar-ticket$ ./submitticket.php?step=2&deptid=1 [L,NC]
RewriteRule ^download$ ./downloads.php [L,NC]
RewriteRule ^carrinho$ ./cart.php [L,NC]
RewriteRule ^extras$ ./cart.php?gid=addons [L,NC]
RewriteRule ^renovar-dominio$ ./cart.php?gid=renewals [L,NC]
RewriteRule ^registrar-dominio$ ./cart.php?a=add&domain=register [L,NC]
RewriteRule ^pagamentos-multiplos$ ./clientarea.php?action=masspay&all=true [L,NC]
RewriteRule ^adicionar-credito$ ./clientarea.php?action=addfunds [L,NC]
RewriteRule ^cartao-credito$ ./clientarea.php?action=creditcard [L,NC]
RewriteRule ^base-de-conhecimento$ ./knowledgebase.php [L,NC]
RewriteRule ^downloads$ ./downloads.php [L,NC]
RewriteRule ^status-da-rede$ ./serverstatus.php [L,NC]
RewriteRule ^sub-contas$ ./clientarea.php?action=contacts [L,NC]
RewriteRule ^emails-enviados$ ./clientarea.php?action=emails [L,NC]
RewriteRule ^mudar-senha$ ./clientarea.php?action=changepw [L,NC]
RewriteRule ^afiliados$ ./affiliates.php [L,NC]
RewriteRule ^suporte$ ./submitticket.php?step=2&deptid=1 [L,NC]
RewriteRule ^transferencia-dominio$ ./cart.php?a=add&domain=transfer [L,NC]
4

1 回答 1

1

不幸的是,您的映射没有统一的模式。您必须拥有高于所有其他规则的第一个规则,以防止无休止的重定向循环

# prevent endless loop    
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]

然后为简单的URL一一添加反向映射

RewriteRule ^clientarea.php$ central-cliente [R,L]

或有条件,如果您有查询字符串

RewriteRule ^clientarea.php?action=details$ meus-dados [R,L]

不起作用,因为?action=details它不是 URL 路径的一部分。你必须有一个RewriteCondwith%{QUERY_STRING}为此

RewriteCond %{QUERY_STRING} action=details
RewriteRule ^clientarea.php$  meus-dados? [R,L]

?末尾的问号会抑制替换 URL 中的查询字符串。

也许,您至少可以将 a RewriteMapwith用于简单的一对一重定向,并在简单的文本文件中维护映射列表。但这与在您的 .htaccesstxt中拥有一长串 s 并没有太大区别。RewriteRule

于 2013-03-17T01:58:25.633 回答