Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8548975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:37:14+00:00 2026-06-11T13:37:14+00:00

I have a query string mysite.com/?local=1 local varies from 1 – 600. For each

  • 0

I have a query string mysite.com/?local=1 local varies from 1 – 600.

For each local is a city name. How can I rewrite the url so that it appears mysite.com/cityname/. I do not mind writing a scenario for each such as if (local ==1){cityname = boston;}.

Is what I’m asking for even possible? So I’d like to take mysite.com/?local=1 and turn it into mysite.com/boston/.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:37:15+00:00Added an answer on June 11, 2026 at 1:37 pm

    index.php:

    <?php
    $map = array(
        1 => 'city',
        2 => 'Portland',
        3 => 'Kaunas',
        4 => 'Hokaido',
        .....
    );
    if (isset($_GET['local']) && intval($_GET['local']) < 600 && intval($_GET['local']) > 0) {
        header('Location: mysite.com/' . $map[intval($_GET['local'])]);
        die(); // Redirect to use the pretty url
    }
    $path = explode('/', explode('?', $_SERVER['REQUEST_URI'])[0]); // might need to expand if php version < 5.4
    $city = $path[1];
    

    .htaccess:

    <IfModule mod_rewrite.c>
        RewriteEngine On
    
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?/$1 [PT,L]
    </IfModule>
    

    Basically what this combo does is if a GET string with variable ‘local’ is passed it will do a redirect with the city id converted to a name. After that you just take the query string and do whatever you want with it

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to redirect from this: www.mysite.com/product.html?item=example to: www.mysite.com/example I have this rewrite
I have a query as follows: String SQL = insert into table (id, name)
I currently have three websites all running from the same DB example websites: www.mysite.com
I have a query string that contains a variable like this $field_name = 'features';
I have a query string: a=1&b=2&c[1]=3&c[2]=4 etc… I want a NSDictionary where a =>
I need to have a query string in my crontab but it isn't working.
I'm always confusing about this stuff. I have this query : string[] names =
I have a dynamic query string that I need to pass via an .htaccess
I have a very basic query string which passes a ID to a receiving
I have a url of a type where query string is like this... ?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.