Search code examples
.htaccesscontent-management-systemdirectoryindex

.htaccess rewrite rule ,last query string is append to the url


Hi i make one cms sites and i need to rewrite my url

current my url is http://www.example.com/index.php?link=pages&cmsid=2&cmsLink=Carpet
it refers the cmsLink
I want my url like http://www.example.com/Carpet
I am using the following code

Options +FollowSymLinks
Options +Indexes
RewriteEngine on
RewriteBase /
RewriteRule ^index.php?link=(.*)&cmsid=(.*)&cmsLink=(.*) $3

Solution

  • To achive this url it not directly possible with .htaccess
    I use regular expression and other tings in htacess as well

    I put remove the cmsid

    current my url is http://www.example.com/index.php?link=pages&cmsLink=Carpet

    RewriteCond %{REQUEST_URI} !/admin
    RewriteCond %{REQUEST_URI} !^/(.*).php
    RewriteBase /
    RewriteRule ^([^/]+)/?$ index.php?link=pages&cmsLink=$1&%{QUERY_STRING} [L]
    

    it return me http://www.example.com/Carpet