简体   繁体   中英

How could I modify my .htaccess to make it work as I want?

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

This is my current .htaccess. It's to make my MVC framework work (www.domain.com/controller/method).

I need to have link like this: www.domain.com/userName.

How (if it's even possible) do I need to modify htaccess folder to make that happen? Because I really don't want to have links like: www.domain.com/controller/method/userName

Just explode your ?url param see if the first string is userName and handle it properly. Also consider implementing userName as a core-level controller. That would keep everything much more structured

If you are using CodeIgniter then set this up as a route under config/routes. What framework are you using?

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