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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:08:05+00:00 2026-06-09T15:08:05+00:00

I am trying to set up a dynamic application-serving framework for a development test.

  • 0

I am trying to set up a dynamic application-serving framework for a development test.

My desired outcome is that when a user goes to a URL, if it is formatted like hostname.com/somecategory/someapplicationname/ or hostname.com/somecategory/someapplicationname (without the slash at the end), it should serve the user the requested application from the database, as long as the category and application name exists as a key.

I have a special case where some applications are not in the database, and they exist on file with that same URL, so we serve the existing file with priority over any database records.

The case with dynamic content from the database works fine. The case for the existing file works 100% only if there is a slash at the end. If the slash is not there, it will serve the right file, BUT the URL looks rather odd. It’ll show: hostname.com/somecategory/someapplicationname/?category=somecategory&appname=someapplicationname
So, it works, but the unexpected output makes me feel that the solution is not complete.

I am using apache mod_rewrite, and my .htaccess file is as follows:

RewriteEngine on
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ route.php?category=$1&appname=$2 [NC,L] 

The PHP code specific to this case is as follows. I stripped the validation and database connection from this snippet for simplicity of reading, but the logic for this particular case is preserved.

$file = $_SERVER['DOCUMENT_ROOT'] . $_GET['category'] . "/" . $_GET['appname'] . "/index.php";
$fileNoPHP = $_SERVER['DOCUMENT_ROOT'] . $_GET['category'] . "/" . $_GET['appname'] . "/index.html";
$_fileExists = file_exists($file);
$_fileNoPHPExists = file_exists($fileNoPHP);
include_once($_fileExists ? $file : $fileNoPHP);

To be clear, my question is: Why is my existing file case appending the GET parameters to the end of the URL, ONLY when the slash at the end is not there?

Thanks for your time. If you need further information, please let me know and I will provide.

  • 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-09T15:08:07+00:00Added an answer on June 9, 2026 at 3:08 pm

    The rule that you have is not what is causing the odd looking URL:

    RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ route.php?category=$1&appname=$2 [NC,L] 
    

    This should be fine. Somewhere you are either generating that link or redirecting the browser to that link. If you have a rule that looks something like this:

    RewriteRule route.php /%1/%2/ [R=301,L]
    

    You need to remove the query string by adding a ? at the end:

    RewriteRule route.php /%1/%2/? [R=301,L]
    

    Or if you’re using Apache 2.4, include a QSD flag in the brackets.

    If that doesn’t solve it, you need to add a rule to ensure a trailing slash gets appended, although it may be an issue with DirectorySlash redirecting for you (which you can turn off).

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

Sidebar

Related Questions

I am trying to make the color scheme of my application dynamic so that
I am trying to create an mac application in XCode that has some of
I'm trying to set dynamic compression in IIS 7 and I know I want
I'm trying to create a tool that converts the dynamic DHCP-provided IPv4 address, gateway
I am a noob at iOS application development. I trying to create UITableView ->
I'm trying set cookies for dynamic features. I've been able to get the on
I am trying to figure out how to set up dynamic dependent selects. This
I'm trying to add dynamic content to my mvc application. I'm using Steven Sanderson
I'm trying to add URL routing to a web application running in Tomcat 5.5.
I have a dynamic textfield and I am trying to set the contents to

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.