How to rewrite url with htaccess for multiple parameters?

How to rewrite url with htaccess for multiple parameters?

I want to rewrite URL, where I have one and two level parameters. first parameter is p and second is sp www.domain.com/home should point to www.domain.com/index.php?p=home and www.domain.com/projects/99 should point to www.domain.com/index.php?p=projects&sp=99

What’s the problem with.htaccess for multiple parameters?

The problem with this htaccess is that it correctly points one level url. ie., www.domain.com/home. But not the two level url. ie. www.domain.com/projects/99

Is it possible to change URLs in.htaccess?

Whilst it’s technically possible to implement this solely in .htaccess, without actually changing the URLs in your application, it’s not recommended. It would deliver a bad user experience and would potentially be damaging to your site’s SEO.

When to set redirect status in.htaccess?

The REDIRECT_STATUS env var does not exist (ie. is empty) on the initial request and is only set after the first internal rewrite/subrequest. (In a per-directory context (like .htaccess ), the rewriting process essentially starts over after the last RewriteRule, and continues to do so until the URL passes through unchanged.

How to make the first rule match the incoming url?

The pattern ^home$ makes the first rule match the incoming URL www.website.com/home. The % {QUERY_STRING} simply captures and appends anything after /home? to the internally substituted URL index.php?page=home. The flag NC simply makes the rule non case-sensitive, so that it matches /Home or /HOME as well.

How many types of rewrites do I have?

I have four different types of rewrites I’m trying to do with multiple parameters in each. However, everything else has completely escaped me. I feel like I’m close, but it’s incredibly frustrating because I don’t know of any way to narrow the problem down. It either works or it doesn’t. Thanks in advance.

Where does the pattern ^ home match the URL?

The Pattern can use a regular expression and is matched against the part of the URL after the hostname and port (with the .htaccess placed in the root dir), but before any query string. The pattern ^home$ makes the first rule match the incoming URL www.website.com/home.