0

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

6
  • @anubhava I need it as a workaround to make a website dynamic
    – adot
    Commented Jun 1, 2018 at 9:33
  • You will need to provide more details in question. Do you want route before every existing file or every non-existing file?
    – anubhava
    Commented Jun 1, 2018 at 9:37
  • 1
    @anubhava Its a slim application with twig as the template engine. These are not links to actual files, its just a route and the function that handles it will respond with the html. I changed the example for better clarity
    – adot
    Commented Jun 1, 2018 at 9:41
  • Can you show us what you tried?
    – C3roe
    Commented Jun 1, 2018 at 9:53
  • I suspect you should not be relying on mod_rewrite rules. Explore routing in slim framework/.
    – anubhava
    Commented Jun 1, 2018 at 10:16

1 Answer 1

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.