1

I want to make my actual url:

http://mywebsite.com/portfolio.php?cat=deportes

Into:

http://mywebsite.com/portfolio/cat/deportes

I've been trying some solutions given on here but none of them work. I can actually get rid of the .php, but do I have to change anything in the a hrefs ?

2 Answers 2

1

Try

RewriteEngine on
RewriteRule ^portfolio/cat/(.+) /portfolio.php?cat=$1 [L]
Sign up to request clarification or add additional context in comments.

Comments

0

starkeen gave you a nice answer. I would suggest to do it for your whole project, not to create rewrite rules for every url you have.

You can have a .htaccess file like this

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

And then to create your logic with php to parse the url itself and call the method / controller or whatever you wish.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.