簡體   English   中英

使用.htaccess的URL前綴

[英]URL prefix using .htaccess

我想使用htaccess文件為傳入的URL加上前綴。 例如,URL可能是http://localhost/george_shop.html ,我希望htaccess像http://localhost/route/george_shop.html一樣給它添加前綴

這是我現在的htaccess:

<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>

更新如果有幫助,這是Slim3 htaccess

我建議您使用苗條的regexp,這樣可以動態地執行以下操作:

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

希望能幫助到你

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM