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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:58:18+00:00 2026-05-26T01:58:18+00:00

I direct all url requests to a front controller. The url requests look something

  • 0

I direct all url requests to a front controller. The url requests look something like example.com/controller/action/etc. The problem is, using relative urls within the program. This works fine if there is only one slash in the url request, but if there is more than one slash, the relative url becomes broken.

At location example.com/controller, relative url other-controller works fine taking the user to example.com/other-controller.

At location example.com/controller/action, relative url other-controller doesn’t work taking the user to example.com/controller/other-controller.

Any recommendations on how to get around this? Hoping I can do this without using absolute paths or some url generating code everytime I want to make a url in the app.

In case it matters, I am currently using this .htaccess code to redirect incomming requests to the front controller:

# Point all to index.php except existing files
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /index.php/$1 [L]
</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-05-26T01:58:19+00:00Added an answer on May 26, 2026 at 1:58 am

    You’re going to need to use absolute URLs to do what you want without looking at the current path you are at and adding the proper number of ..s. You don’t need to have the domain for each one, you can just use URLs like /controller/action and /other-controller/action. These will work for both controllers seamlessly. A sample anchor tag:

    <a href="/controller/action">Do something!</a>
    

    As a side note, oftentimes, people will write functions to generate URLs. If you are using a MVC framework, it may be in the form of adding a method to a model and call the function get_absolute_url which returns the form I mentioned above.

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

Sidebar

Related Questions

I would like to direct all url requests to a single php file. This
Is it possible to redirect all requests to x.domain.com/.* to y.domain.com/.* WITHOUT letting this
Using httplib2 and urllib2, I'm trying to fetch pages from this url, but all
I want to use URL of current page in all my pages on my
If I have a route: routes.MapRoute( RouteName, // route name {action}, // url with
I have some code like: header('Refresh: 15; url=' . $url); This works fine, except
My application currently has a very simple URL layout: map.resource :account, :controller => users,
Update: I'm using a shared CakePHP lib across several apps (with all of them
I have the following page: www.domain.com/index.php?route=information/contact and I'd like to rewrite it so that
When using URL rewriting for beautification, are there any thoughts on whether to do

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.