简体   繁体   English

如何将特定的文件夹重定向到index.php

[英]How to redirect specific FOLDER to index.php

Hi i have this web sctructure: 嗨,我有这个网络结构:

/css/
/js/
/img/
/dashboard/
/pages/
/index.php

I got this .htaccess file 我得到了这个.htaccess文件

# Setting default charset
AddDefaultCharset utf-8

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /web
RewriteRule ^([\w\-]+)/?$ index.php?page=$1
</IfModule>

Works ok, if i write myurl/login redirect to index.php?page=login but i wanna to redirect this myurl/dashboard to index.php?module=dashboard and myurl/dashboard/login to index.php?module=dashboard&page=login 正常工作,如果我将myurl / login重定向到index.php?page = login,但我想将此myurl / dashboard重定向到index.php?module = dashboard,将myurl / dashboard / login重定向到index.php?module = dashboard&page =登录

but isnt work with my .htaccess, can you help me? 但是不能与我的.htaccess一起使用,您可以帮我吗? im trying redirecto ALL to index.php but doesnt work, cause redirect /img, /js, /css folder to index.php and i cant see my web 我正在尝试将全部重定向到index.php但无法正常工作,导致将/ img,/ js,/ css文件夹重定向到index.php,我看不到我的网站

Thanks in advance. 提前致谢。

Have it this way: 有这种方式:

RewriteEngine On
RewriteBase /web/

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

RewriteRule ^(dashboard)/?$ index.php?module=$1 [L,QSA]

RewriteRule ^(dashboard)/([^/]+)/?$ index.php?module=$1&page=$2 [L,QSA]

RewriteRule ^([\w-]+)/?$ index.php?page=$1 [L,QSA]

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

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