Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7651559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:32:14+00:00 2026-05-31T11:32:14+00:00

I am having an issue with using an .htaccess file to rewrite my urls

  • 0

I am having an issue with using an .htaccess file to rewrite my urls without .php in them. It works for some addresses, but not others. Here is what is in my .htaccess file..

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/$ $1.php

#rewrite url up to 3 levels
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/$ /$1/$2/$3.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

I have the following folder/file structure on my site..

index.php
about-us
  index.php
  careers.php
our-work
  index.php
  test.php
  client1
    example.php

The following urls work..

example.com

example.com/about-us

example.com/our-work

example.com/our-work/client1/example

But these do not work..

example.com/our-work/test

example.com/about-us/careers

I just get a 404 error.

Any idea why this is happening?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T11:32:15+00:00Added an answer on May 31, 2026 at 11:32 am

    You don’t have a 2 level rule, just a 1 level and 3 level rule. You should add:

    #rewrite url to 2 levels
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
    

    You should probably prefix your 3 level rule with the RewriteCond conditions also:

    #rewrite url to 3 levels
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^([^/]+)/([^/]+)/([^/]+)/$ /$1/$2/$3.php
    

    This will prevent the rule being invoked if there is a directory with the same name or the PHP file does not exist.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an issue using Stripes validation method. It works but rather than returning
having an issue using a NSMutableArray; In my implementation file applicationDidFinishLaunching method I have
Having an issue using JSTL and Spring...it's not allowing me to iterate over my
I am having some issue here using LWP::Simple to get ftp site content in
i'm having a little issue with modrewrite under php. this is inside my .htaccess
I am having a small issue using the classic WebLogin snippet (Not WebLoginPE) in
I'm having an issue using a column alias for a join in a cte.
I am having a issue using Google's SDC (Secure Data Connector) with my Google
I'm having an issue using the Cookie class of the Servlet API 2.5 on
I'm having an issue using the qTip plugin with jQuery. I've created a js

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.