简体   繁体   中英

URL prefix using .htaccess

I want to prefix the incoming URL using an htaccess file. For example, the URL might be http://localhost/george_shop.html , I want the htaccess to prefix it like http://localhost/route/george_shop.html

This is my htaccess right now:

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]

    RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
    RewriteRule ^(.*) - [E=BASE:%1]
    RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
</IfModule>

Update If it helps, this is the Slim3 htaccess

I suggest you use slim regexp, your route can by dynamic by doing something like so:

$app->get('/{route:.*(?:html)$}', function($req, $res, $args) {});

Hope it helps

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