php - How to setup a permalink structure like wordpress with just postname after the domain name?


My title should be enough to make you understand that what I am actually trying to do. I just want to make a simple permalink structure like this:

I have written all the code to get user request, my code is

$permalink = trim($_SERVER['PHP_SELF'], "/");. 

After that I have managed to get the user request whenindex.php is added in the URL like this:

But this is not what I am trying to achieve, I just want to simple URL structure like this:

I want a way so that I can get user request without any need ofindex.php in the URL.

Thanks, any help will be highly appreciated.




The answer is .htaccess:

RewriteEngine on
RewriteBase /
RewriteCond  %{REQUEST_FILENAME} !-f
RewriteCond  %{REQUEST_FILENAME} !-d
RewriteRule  ^(.*)$ index.php?param=$1 [QSA,L]

See: Redirect everything to index.php

People are also looking for solutions to the problem: php - Telegram Inline Query - No Search Result


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.