简体   繁体   中英

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

# 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

but isnt work with my .htaccess, can you help me? 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

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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