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 8455573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:19:10+00:00 2026-06-10T12:19:10+00:00

My mod_rewrite is working excellent, but it’s not recognizing anything after for example /calgary/

  • 0

My mod_rewrite is working excellent, but it’s not recognizing anything after for example /calgary/

So, if I go to /calgary/login.php and it is only seeing the index.php page? It won’t recognize the /login.php page?

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /city_name

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*)/?$ /city_name/index.php?page=$1 [L,QSA]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} /([^\./]+)\.php$
    RewriteCond %{DOCUMENT_ROOT}/city_name/%1.php -f
    RewriteRule ^(.*)/([^\./]+)\.php$ /city_name/?$2.php?page=$1 [L,QSA]
</IfModule>
  • 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-10T12:19:11+00:00Added an answer on June 10, 2026 at 12:19 pm

    You need to swap those 2 rules:

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /city_name
    
        # This used to be the 2nd rule
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_URI} /([^\./]+)\.php$
        RewriteCond %{DOCUMENT_ROOT}/city_name/%1.php -f
        # there used to be a "?" here, remove it ----v
        RewriteRule ^(.*)/([^\./]+)\.php$ /city_name/$2.php?page=$1 [L,QSA]
    
        # this used to be the first rule
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule (.*)/?$ /city_name/index.php?page=$1 [L,QSA]
    </IfModule>
    

    The less restrictive rule (the one that matches (.*)/?$) will match /calgary/login.php outright before the second set of rules gets to do its thing, which seems to be rewritten to /city_name/?login.php?page=calgary.

    Is that really what you want? There are two ? in the target there. Maybe you only want /city_name/$2.php?page=$1?

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

Sidebar

Related Questions

I'm trying to add mod_rewrite rules in the vhost config but it's not working.
I am working on a site maintainence. It uses mod_rewrite technique. But im new
I'm using mod_rewrite to rewrite .html to .php. RewriteRule ^([0-9a-zA-Z-_]+)\.html$ index.php?p=$1 [L] But, I'm
I'm working on a new project, using Apache's mod_rewrite and PHP to get pretty
I am using .htaccess and mod_rewrite in my little PHP framework. It's working nicely,
I have not having any luck getting my .htaccess with mod_rewrite working. Basically all
I have a mod_rewrite rule working to direct non-existing directories to a php file
I am having an issue with getting mod_rewrite rules working in .htaccess after moving
Hey, I am trying to use mod_rewrite to make http://example.com/style/universal.css show the page http://example.com/style.php?n=universal
I'm trying to get mod_rewrite working with the following URLs: /events.php?view=details&id=$var /events.php?view=edit&id=$var Obviously my

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.