繁体   English   中英

htaccess多个页面重定向

[英]Htaccess multiple redirect for one page

我有一个问题:我在将来的网站上做了一个空白页,但我遇到了问题。

这些网址(account.php)提供了一个页面:

http://site.domain/en/account/-可以访问,但如果没有/,则无法访问
http://site.domain/en/account/create/-可以访问,但是我有同样的问题http://site.domain/en/account/create/verify/-无法通过当前访问htaccess的

我的htaccess看起来像这样:

RewriteEngine On
AddDefaultCharset UTF-8
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]
RewriteCond %{HTTP:Accept-Language} ^([a-z]{2})- [NC]
## Rewrite Rules
RewriteRule ^account/?$ /%1/%{REQUEST_URI} [L,NC,R]
RewriteRule ^([a-z]{2})/(account)/([^/]+)/([^/]+)?$ /$2.php?language=$1&type=$3 [L,NC,QSA]

因此,我想做的是使所有重定向都可以通过htaccess访问。

例如,使用上述htaccess中的数据,将无法访问帐户页面和创建页面,但不能访问验证页面。 如果我将其更改为:

RewriteRule ^([a-z]{2})/(account)/([^/]+)/([^/]+)/([^/]+)?$ /$2.php?language=$1&type=$3&subtype=$4 

我可以访问创建和验证页面,但不能访问帐户页面本身。

因此,我要实现的目标是,能够使用一个htaccess规则访问所有这3个页面,因此,基本上,仅使用htaccess重定向用户,而无需php的帮助,即使account.php确定了发出哪个请求并为请求提供正确的页面

是否有关于htaccess和相关问题的好书可供阅读,因为我不知道它是什么以及如何使用它

有这种方式:

AddDefaultCharset UTF-8

RewriteEngine On
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]

RewriteCond %{HTTP:Accept-Language} ^([a-z]{2})- [NC]
## Rewrite Rules
RewriteRule ^account/?$ /%1%{REQUEST_URI} [L,NC,R]

RewriteRule ^([a-z]{2})/(account)(?:/([^/]+)(?:/([^/]+))?)?/?$ /$2.php?language=$1&type=$3 [L,NC,QSA]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM