2021年3月18日星期四

Redirect dynamic url with single non-numeric parameter to static extension-less root level url with name consisting of parameter value text

I have an .htaccess that allows me to use .php files urls without extension:

    # if not a directory and .php file is present then add .php extension      RewriteCond %{REQUEST_FILENAME} !-d      RewriteCond %{DOCUMENT_ROOT}/$1.php -f      RewriteRule ^(.+?)/?$ $1.php [L]  

I am trying to create a controller page.php file that will allow me to generate multiple dynamic pages depending on the parameter value, such as:

https://www.example.com/page.php?pid=some-page-slug-1

https://www.example.com/page.php?pid=some-page-slug-2

and so on.

I would like to turn the above dynamic links to static in the next fashion:

https://www.example.com/page.php?pid=some-page-slug-1

turns to:

https://www.example.com/some-page-slug-1

I've tried to modify some template I found on internet but its not working:

RewriteRule (.*)\.php$ page.php?pid=$1  

What is the correct markup to rewrite dynamic url with single non-numeric parameter to static extension-less root level url with name consisting of parameter value text in a SEO friendly way?

https://stackoverflow.com/questions/66698808/redirect-dynamic-url-with-single-non-numeric-parameter-to-static-extension-less March 19, 2021 at 04:39AM

没有评论:

发表评论