Browser URL without the extension

Dear readers…


Now I have encountered a new problem …

I found some “rewrite rules” for not having to type .php in the browser.

e.g. “mypage.com/clothes” instead of “mypage.com/clothes.php”.

But when I send a request like this:
mypage.com/clothes/dresses

…Problems occurs because there is no folder with that pathname.

But I want it to work the same as if I had written mypage.com/clothes.php/dresses.


Someone who wants to help me here?

Best regards
Neo

I’m confused by this statement.
Do you mean you want it to behave like you wrote mypage.com/clothes/dresses.php ? cause your version, clothes.php is a directory name. PHP pages dont have subpages.

You can write a rule to do this, but it will prevent you from visiting actual directories’ default pages.

I think you should read up about “Clean/Pretty Urls” and study thoroughly

2 Likes

Hello hutley. Hope everything’s good.

I know php doesn’t have subpages.

Let’s say I have a page called clothes.php. If I send a request to mypage.com/clothes.php/dresses, then there is no problem … [‘path_info’] will store “/dresses”.

But if I send to “mypage.com/clothes (without .php) / dresses” it doesn’t work … So I added a rewrite rule so I could write “clothes” without “php” (which worked), but not if I extended with dresses (e.g. clothes / dresses) …


It’s okay if I change something and it prevents apache from listing the file system, the above is more important in this case

Then what you’ve done is not send a request to clothes.php.

As John’s link points out, there are ways of doing this, though i must say I don’t like the idea of it for just moving mypage.com/clothes.php?dresses to mypage.com/clothes/dresses, but to each their own.

It is okay. If you know a solution I would appreciate if you could help me here, you mentioned something about writing a rule …

Off Topic:

Please use example.com for example URLs, or wrap the URLs in code tags.

You could write a rule for it, but you’d have to either be very specific, or very careful.
So, lets tick off a few boxes so that those that actually know how to write the rewrite rules you need can give you want you want;

  1. Is this the only page and sub category you want this to apply to?
  2. Does this apply to all pages on your domain?
  3. Does this mean you won’t have any subdirectories on your domain?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.