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

144
Visualizações
Getting file and folder issues using htaccess file in PHP

I am working for a blog system using PHP PDO. I have created a post.php page in my root folder. In the same root, I have an Admin folder. I am getting posts from databases like -

example.com/cat_slug/post_slug 

i.e

example.com/php/how-to-learn-php 

As you can see there is no post keyword in the URL because of the .htaccess file.

RewriteEngine On  
 RewriteRule ^([^/]*)/([^/]*)$ post.php?cat=$1&postSlug=$2 [L]

It's correct according to my need but in the same folder, I have the Admin folder(where post.php is located ). The Admin folder contains folders and files. Now, when I open the Admin folder it's going to post.php

like -

example.com/Admin 

and it's going to example.com/Admin and output - undefine - slug ad cat. I want to that when I visit the Admin folder it should open Admin files not redirect to the post.php file. I have many folders in my root same as Admin. All are going to post.php execution.

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

0

Try something like this:

RewriteEngine On  

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)$ post.php?cat=$1&postSlug=$2 [L]
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