admin管理员组

文章数量:1287496

How should I approach this issue?

I want to create one page, but many "virtual pages", e.g. like a productinfo.php. A product has several. In this case you manually create the posts in the database through dashboard and the virtual pages are pointing to specific posts in the WP database.

What I want is this is kind of same thing but I don't want to add any posts and I want all virtual pages to redirect to same page with different GET request:

Let met explain:

  1. I create one page: e.g. cityinfo
  2. If I go to /luton it should point to cityinfo?actualcity=Luton
  3. If I go to /london it should point to cityinfo?actualcity=London etc.

Should I be using .htaccess for this? Or am I missing some easier/better way to achieve this?

How should I approach this issue?

I want to create one page, but many "virtual pages", e.g. like a productinfo.php. A product has several. In this case you manually create the posts in the database through dashboard and the virtual pages are pointing to specific posts in the WP database.

What I want is this is kind of same thing but I don't want to add any posts and I want all virtual pages to redirect to same page with different GET request:

Let met explain:

  1. I create one page: e.g. cityinfo
  2. If I go to /luton it should point to cityinfo?actualcity=Luton
  3. If I go to /london it should point to cityinfo?actualcity=London etc.

Should I be using .htaccess for this? Or am I missing some easier/better way to achieve this?

Share Improve this question edited Oct 15, 2021 at 16:16 bestprogrammerintheworld asked Oct 15, 2021 at 15:27 bestprogrammerintheworldbestprogrammerintheworld 1,3212 gold badges19 silver badges40 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 1

I actually found a rather easy way to achieve this:

add_rewrite_rule( 'city/([a-zA-Z]+)/?$', 
'wp-content/plugins/csv-to-html/templates/csvtohtmlpage_core.php?city=$1' );

Yes, I know I did not mention city/ in the beginning but I just wanted wanted to know how should I achieve this. If someone has better ideas. Please tell me! :-)

本文标签: redirectUse virtual pages point to one specific page