Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

187
Visualizações
how to get PHP Smart URL

My website has URL like this

domain.com/profile.php?id=your_profile_id

now how do i turn it into URL like this

domain.com/profile/your_profile_id

I tried this thing in .htaccess

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]

and it's just helps me to remove .php extension. not the exact thing what i want. Thanks in advance. have a great day.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

With your shown samples, please try following rules. Please make sure to place your htaccess file along with your profile.php file.

Also please make sure to clear your browser cache before testing your URLs.

RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/(.*)/?$ $1.php?id=$2 [QSA,L]
over 4 years ago · Santiago Trujillo Relatório

0

what you want to do actually? see if you want to show result as per URL on none existing page / 404 page code on 404 page , if you just want URL for statements you can go with simple $_SERVER['REQUEST_URI'];

after fetching URL perform such

$myURL = $_SERVER['HTTP_REFERER']; // e.g https://www.anything.com/profile.php?id=your_profile_id

$myURL = str_replace("https://","",$myURL );
$myURL = str_replace("http://","",$myURL );
$myURL = str_replace("www.","",$myURL );
$myURL = str_replace(".php","",$myURL );
$myURL = str_replace("?","/",$myURL );
$myURL = str_replace("id=","",$myURL );

output : anything.com/profile/your_profile_id
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda