Call php code with Query String
-
Greetings,
I have a wordpress page that contains custom php code.
Let’s say the page name is called myphpcode.
I have a url that looks like: https://www.mysite.com/myphpcode/var1-var2-var3
The var1-var2-var3 is meant to be a hyphen delimited parameter list
that the myphpcode program will parse as a query string.
This is supposed to be SEO friendly URL – so each var# parameter is meant to be a signifcant keyword for the search engines.The wordpress site is using a permalinks setting: /%postname%/
Thus the other links for posts look like:
https://www.mysite.com/category/my-first-topic
https://www.mysite.com/category/my-second-topic
https://www.mysite.com/top-ten-holiday-gift-ideasSo, in this example, I am assuming
my-first-topic and top-ten-holiday-gift-ideas
function like an html file.When I call https://www.mysite.com/myphpcode
the code runs OK and a default page is displayed since it has not
yet received any query string values.When I call https://www.mysite.com/myphpcode/var1-var2-var3
wordpress says The page you requested could not be found.I am using the following .htaccess
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^myphpcode/(.*)$ https://www.mysite.com/myphpcode?parm1=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]I was hoping the RewriteRule with the myphpcode reference
would execute the myphpcode and pass the var1-var2-var3 as a query string into parm1. I am guessing that it sees the myphpcode as a wordpress category instead of a wordpress page with php code and that it sees the var1-var2-var3 as html code which of course it is not.To summarize: Is it possible to have a wordpress URL that does not have a conventional query string – https://www.mysite.com/myphpcode?parm1=var1&parm2=var2 but rather one that looks like
https://www.mysite.com/myphpcode/var1-var2-var3It must be SEO friendly with this convention but also be recognized by wordpress as a wordpress page(the myphpcode part) and pass the var1-var2-var3 part to the php program as a query string?
Since I am relatively new to wordpress I am in need of some
more experienced eyes.Thank You.
[duplicate: https://www.ads-software.com/support/topic/call-php-code-with-query-string?replies=1 – closed]
- The topic ‘Call php code with Query String’ is closed to new replies.