简体   繁体   English

htaccess:友好的网址-斜杠和“假子目录”

[英]htaccess: friendly url - trailing slash and “fake subdirectories”

I want to make fake-subdirectories with htaccess ( fakefolder/forget-password with rewrite mod), but it doesn't really working for me... 我想用htaccess制作假子目录(带有重写mod的fakefolder/forget-password ),但对我来说真的不起作用...

I have this url: 我有这个网址:

parent-directory/index.php?version=1&do=forget-password&email=example@domain.com&token=85085ab92fcfd5dada280c73f7f494ec

* note: the 'email' variable is being verified with mysql, and I use filter_var in case the value is an email so it can be also username instead ( email=username ). *注意:'email'变量正在使用mysql进行验证,如果值是电子邮件,则我使用filter_var ,因此它也可以是用户名( email=username )。 parent-directory is a real directory. parent-directory是真实目录。 version is dynamic, and can be 2 or 3 or string, and show a different result, so in this case version=1 is fakefolder . version是动态的,可以是2或3或字符串,并且显示不同的结果,因此在这种情况下, version=1fakefolder version=2 and any other value can be anything else ( fakefolder2 ) version=2 ,任何其他值都可以是其他任何值( fakefolder2

and this htaccess code: 和这个htaccess代码:

Options +FollowSymLinks -MultiViews
RewriteEngine On

# Set configuration file
php_value auto_prepend_file configuration.inc.php

# Start Rewriting
RewriteBase /parent-directory/

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule ^fakefolder$ index.php?version=1 [QSA,L]

if I try to make something like this: RewriteRule ^([az])$/forget-password$ index.php?version=$1&do=forget-password [QSA,L] it's not working, or showing 404 如果我尝试进行以下操作: RewriteRule ^([az])$/forget-password$ index.php?version=$1&do=forget-password [QSA,L]无效,或显示404

Is it possible? 可能吗? (if yes, then can it be multileveled? eg index.php?version=1&do=forget-password&email=example@domain.com -> ([az])$/forget-password/username instead of fakefolder/forget-password?email=... )? (如果是,那么它可以进行多级处理吗?例如index.php?version=1&do=forget-password&email=example@domain.com -> ([az])$/forget-password/username而不是fakefolder/forget-password?email=... )?

Please excuse my english and thanks a lot. 请原谅我的英语,非常感谢。

Try these rules: 尝试以下规则:

# Set configuration file
php_value auto_prepend_file configuration.inc.php

Options +FollowSymLinks -MultiViews
RewriteEngine On
# Start Rewriting
RewriteBase /parent-directory/

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

RewriteRule ^([\w-]+)/forget-password/([\w-]+)/?$ index.php?version=$1&do=forget-password&email=$1 [QSA,L,NC]

RewriteRule ^([\w-]+)/forget-password/?$ index.php?version=$1&do=forget-password [QSA,L,NC]

RewriteRule ^fakefolder/?$ index.php?version=1 [QSA,L,NC]

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

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