Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!