Multiple Rewrite rules with .htaccess

1

I currently have the following .htaccess:

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /

## Esconder .PHP
    # Redirecionamento externo de /dir/foo.php para /dir/foo
        RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
        RewriteRule ^ %1 [R=302,L]

    # Redirecionamento interno de /dir/foo para /dir/foo.php
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME}.php -f
        RewriteRule ^(.*?)/?$ $1.php [L]


## Redirecionamento para o parametro P do GET na index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?p=$1 [NC,L,QSA]

# Esconder a palavra "index"
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index($|\ |\?)
    RewriteRule ^ /%1 [R=301,L]
</IfModule>

Now I have to pass a parameter to one of the pages that is already accessed by the index.php?p=$1 rule that in the case exists and works in the URL:

www.site.com.br/portfolio?trabalho=14

Now I need to merge the rules to get the url above from:

www.site.com.br/portfolio/14

Is it possible? Can you help me?

Thank you!

    
asked by anonymous 12.04.2017 / 01:01

1 answer

0

You can add the code below right after the block # Redirect

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)$ index.php?p=$1&id=$2 [L]

So you will be getting the second parameter after the slash and php will get in the variable get id ($ _GET ['id'])

    
12.04.2017 / 02:38