Hi,
I need some help to understand .htaccess and URL Rewriting,
Actually, my site works if user use an url like this:
mysite.local/index.php?q=register&v=index&p=params
I want to rewrite this to:
mysite.local/register/index/?p=params
or something more "pretty".
Actually I write this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1&v=$2&p=$3 [QSA,L]
But this don't works very well... And I can't find easy explanation to do exactly what I want, but seems achievable, cause' some framework do it.
(I understand what does the RewriteCond, but the writing of RewriteRule is not very clear to me)
>>56955857
You know how RegEx work?
Try something like this: ^\?q=(.*)&\?v=(.*)&\?q=(.*)$
See:
>https://www.sitepoint.com/apache-mod_rewrite-examples/
>>56956479
Ah wait, I got it backwards..
You want something like this:
RewriteRule ^(.*)/(.*)/(.*)$ index.php?q=$1&v=$2&p=$3 [QSA,L]
Bascially you should look into Regular Expressions, you grab what's inside the braces.
>>56955857
There is no point in "pretty URLs".
>>56956586
They are typically shorter and look nicer.
If you take the time and write URL slugs for your pages it can help slightly with SEO./recipes/apple-pieis better than/recipe.php?id=558.
>>56956522
Thanks, it works :)
(I don't use regex often, but seems logic now... I was trying to reuse some htaccess configuration from other framework like Yii)