0

I have a website that has many URLs that look like this:

https://www.website.com/view?id=56
https://www.website.com/category?name=music

Which I would like to look like this:

https://www.website.com/view/56
https://www.website.com/category/music

This website is deep into development and it is too late to switch to a framework that makes this simpler.

My question is: What is the simplest way to do this (again, without using Klien or Composer, or any other framework-type things)? Perhaps something in .htaccess or something along those lines.

Thanks! Eric

1 Answer 1

1

You can enable mod_rewrite in your apache config and rewrite what you want with some rules.

Try this ones:

RewriteEngine on
RewriteRule ^view/([0-9-]+)/?$ view?id=$1 [NC]
RewriteRule ^category/([A-Za-z0-9-]+)/?$ category?name=$1 [NC]
Sign up to request clarification or add additional context in comments.

7 Comments

Thank you, I'll try this
I tried it and it did not work. The page is loading but without any CSS or PHP (just the plain html)
Could you post your css url?
Sorry but it's not online yet because it is still being developed. I'll keep trying different things
Actually, I figured it out. It was looking for files inside a folder called /view/ which doesn't exist. Thank you for your help!
|

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.