Hello I've got a site that uses php and mvc and I've got a link http://localhost/kipsalahome/post?title=Title-of-the-news-2&lang=En that I want to convert into http://localhost/kipsalahome/post/Title-of-the-news-2/En and still be able to use $_GET[''] I'm using this code in htacces
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
RewriteEngine On
# Remove php extensions from a file extension
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^post/([0-9a-zA-Z_-]+)/([a-zA-Z]+) post.php?title=$1&lang=$2 [QSA,NC,L]
# Hide local file structure
Options -Indexes
but sadly it does nothing for me. I would like to know what i'm doing wrong and how could i fix it.
You need the rule as below:
RewriteRule ^post/(.*)/(.*) post.php?title=$1&lang=$2
Refer: https://code.tutsplus.com/tutorials/using-htaccess-files-for-pretty-urls--net-6049
in my test the above htacesss worked correctly:
URL: http://server/test/post/Title-of-the-news-2/En
post.php -> print_r($_GET);
resultado: Array ( [title] => Title-of-the-news-2 [lang] => En )
To use more parameters in the url do so:
URL http://server/teste/post/Title-of-the-news-2/En?sandbox=true
post.php -> print_r($_GET);
resultado: Array ( [title] => Title-of-the-news-2 [lang] => En [sandbox] => true )
Thanks everyone for answers i'll look through them all, but i found temporary solution by creating my link that way <?php $link = URLROOT. "post/" .$newsVal->Blog_Title_En.'/'
and then exploding it on other page to get needed variables.