简体   繁体   中英

regex for creating pritty urls in htaccess

What is the right regex to

create this url: domain.nl/projecten/scheidingswanden from

http://www.domain.nl/?module=projectencat&action=scheidingswanden

in other words: replace the variable names?module= and &action= with slashes

but also the other way around because the frontcontroller needs to read the get variables module and action

I don't know if it's only.htaccess, but this logic is missing

thanks, Richard

RewriteRule  ^([^/])/([^/])$    ?module=projectencat&action=scheidingswanden  [L]

This may help:

RewriteEngine on
RewriteRule ^([a-zA-Z]+)/(.*)/index.html$ index.php?module=projectencat&action=scheidingswanden

[a-zA-Z]+ = requires one or more alphabetic chars
(.*)      = requires one or more any kind of chars

Is this what you are looking for:

RewriteRule  ^([^/]+)/([^/]+)$    ?module=$1&action=$2

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