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

  • SEARCH
  • Home
  • 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 8557823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:39:43+00:00 2026-06-11T15:39:43+00:00

I working on project that displays item according to the location. First time user

  • 0

I working on project that displays item according to the location. First time user has to pick a location in order to search for an item. This location is saved as cookie for future reference. The url looks as following:

 www.example.com/newyork

If the user is looking at an item that exists in New York, the url for that item is:

 www.example.com/item/iphone

Above url works fine but there is one problem. If the above url is forwarded through an email to a first time user, This item does not exist because the location is not selected. I could forward user to different page to select location and then look for the item, but this is hassle for the user. So, I would like to change above url to

 www.example.com/newyork/item/iphone

so that way I could use New York as location. How do I add a non-existing sub directory to a url? Canthis be done with PHP or done with mod_rewrite?

  • 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-11T15:39:44+00:00Added an answer on June 11, 2026 at 3:39 pm

    You can try doing a redirect, but you’ll have to carefully craft the regular expression used to match /newyork/item/iphone. Then you can group out the newyork part and set a cookie and redirect the browser using the CO flag.

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^/?([^/]+)/item/([^/]+)$ /item/$2 [L,R,CO=location:$1:example.com:/]
    

    This will take a request like http://www.example.com/pittsburgh/item/iphone and extract the pittsburgh part, store it in a cookie named location (with the domain=example.com and path=/), then redirect the browser so the cookie gets stored by the browser and make the browser go to http://www.example.com/item/iphone

    See the documentation for the CO flag for details about the syntax:

    [CO=NAME:VALUE:DOMAIN:lifetime:path:secure:httponly] 
    

    Quick question. The acutal link without mod_rewrite rule is www.example.com/item.php/itemid=phone. Is it possible to rewrite this link to www.example.com/newyork/item.php/itemid=phone

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^/?([^/]+)/item.php/itemid=(.+)$ /item.php/itemid=$2 [L,R,CO=location:$1:example.com:/]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im working on a project that has an implementation of JOSSO in place. We
I am working on a project that already has begun being developed. ON some
I am working on internationalizing a project that has a custom date picker. The
I am currently working on a project which contains a window, that has a
My company has been working on a Flex dashboard that displays realtime financial information.
I can't see why this isn't working. I have a list, each item has
I am currently working on a project that dynamically displays DB content into table.
i am working on a project that displays posts type within a radius entered
I am working on a project that displays a PDF in a UIWebView. I
I am currently working on a project that requires me to display PDF documents

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.