Jump to content

Custom Links


mrnikper

Recommended Posts

Hey! I have a question please. First of all let me explain, My server dosn't accept .htaccess, they using nginx, and I don't have access to nginx files too.
Now, I want to make custom urls for my custom website, but there is a problem, I don't want everything to be to the main root (www). I want to put the files inside the folders, but still I want the urls to be diffrent.
I want the login page to be in specific folder with the name access, but I want the visitor to see it like: .com/login and no .com/access/login.
I found a solution to change the 404.php see bellow to understand:

<?php

require_once 'inc/routes.php';

$request_uri = $_SERVER['REQUEST_URI'];

if ($request_uri == '/') {
    // Show the homepage
    include('index.php');


} elseif ($request_uri == '/login') {
    // Show the about page
    include('access/login.php');
    
} else {
    // Show a 404 error
    http_response_code(404);
    include('error.php');
}
?>

That supose to do what I have in my mind, and works I see the page, but the problem is the buttons stop working.
The user see /login on the search bar, but the real name of the page is 404.php and the login.php file cannot submit any request because actually the login change to 404.
So the buttons dosn't work.
There is any other way to make custom links, to put every php file in specific folder, but still use custom url to navigate the users there?

Or to do something in action of submit, to forward the proccess, to complete the proccess, but the user not see any diffrence to the url?

Edited by mrnikper
Link to comment
Share on other sites

The correct solution is to use something set up in the server configuration to let you do URL rewriting - without having to resort to anything to do with 404 pages.

Have you tried asking the people who run the server what they can offer you in the form of URL rewriting? It's an extremely common behavior for websites so it's hard to believe they aren't providing you a way to do it.

Link to comment
Share on other sites

Ask for help to them, and the say to send the links to do it, but I can't send message every time and w8 them to complete the proccess.

At the end, how worpress, joomla and other platforms do it without problem? I see wordpress have .htaccess but my hosting dosn't read it, but the links are custom without problem, without need to setup anything on the server.

Must be something 😕

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.