htaccess rewrite redirect with parameters in subfolder

后端 未结 2 761
执念已碎
执念已碎 2021-01-24 10:26

I want that when you go to url: http://www.example.com/subdir/paramvalue

redirects to

http://www.example.com/subdir/index.php?param=paramvalue

My .htacce

2条回答
  •  佛祖请我去吃肉
    2021-01-24 10:44

    Thanks anubhava ! First i edit 000-default from /etc/apache2/sites-available/ and add:

    
        AllowOverride All
    
    

    Then the solution in .htaccess was:

    RewriteEngine On
    RewriteBase /subdir/
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?param=$1 [QSA,L]
    

    Finally in /subdir/index.php

    I get the value paramvalue as:

    $myParamValue = $_GET["param"];
    echo myParamValue 
    

    it returns : paramvalue

提交回复
热议问题