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

  • SEARCH
  • Home
  • 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 9313199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:49:14+00:00 2026-06-19T01:49:14+00:00

i had a rewrite rule working fine where any pages in the format site.com/dir/page1.php

  • 0

i had a rewrite rule working fine where any pages in the format site.com/dir/page1.php were translated into the format site.com/page1. i achieved that with:

# 1. turn on the rewriting engine
RewriteEngine On

# 2. remove the www prefix
RewriteCond %{HTTP_HOST} ^www\.site\.com [NC] 
RewriteRule ^(.*)$ http://site.com/$1 [L,R=301]

# 3.  send all non-secure pages to secure pages
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

# 4. if 404 not found error, go to homepage
ErrorDocument 404 /index.php

# 5. if url received with trailing slash (e.g. http://domain/test/) then go to correct page (e.g. http://domain/pages/test.php)
RewriteRule ^([^.]+)/$ includes/$1.php

# 6. if url received WITHOUT trailing slash (e.g. http://domain/test) then go to correct page (e.g. http://domain/pages/test.php)
RewriteRule ^([^.]+)$ includes/$1.php

i have now set up a blog at site.com/blog/ and when i try and visit the blog it is displaying the home page (ie a 404 error).

i think the error is at part #5 and #6 and that somehow i need to specify that the rewrite rule is specifically only for the ‘includes’ directory? but i could be wrong, any help appreciated, thank you!

update:

i tried the solution to ignore the ‘blog’ directory here:

How to configure .htaccess file for rewrite rules to get rid of extensions, trailing slashes, www?

#skip wordpress site which starts with blog
RewriteCond %{REQUEST_URI} !^/blog [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

but that didn’t work for me unfortunately.

  • 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-06-19T01:49:15+00:00Added an answer on June 19, 2026 at 1:49 am

    To prevent rewriting on the blog/, place the following before your rules 5,6 (which are generi rewrites):

    # Do not apply the following to the blog
    RewriteCond %{REQUEST_URI} !^/blog
    
    # 5. if url received with trailing slash (e.g. http://domain/test/) then go to correct page (e.g. http://domain/pages/test.php)
    # Merged 5 & 6 together by making the trailing slash optional /?
    RewriteRule ^([^.]+)/?$ includes/$1.php
    

    Another possibility is to prevent rewriting on any directory that exists:

    # Do not apply the following to actual existing files and directories
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # Merged 5 & 6 together by making the trailing slash optional /?
    RewriteRule ^([^.]+)/?$ includes/$1.php
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had a mod-rewrite rule that worked just fine for a few months: RewriteEngine
I'm using mod_rewrite to transform: www.example.com/view.php?ID=1234 into www.example.com/1234 using the following rule: Options +FollowSymlinks
I've been working on integrating deeplinking into a wordpress site im developing; http://dhp.camoconnell.com/ the
I had this rewrite rule in my httpd conf file: RewriteRule (.*?)\.html $1.php?%{QUERY_STRING} [NC]
Had received a module from CCAVENUE and it was working fine with Magento 1.6.2...
Had a page that was working fine. Only change I made was to add
I want to create shorter links for my site, eg site.come/u/1 instead of site.com/user.php?u=1
I have a RewriteRule in my site and it's working fine but 1 part
When I use a rewrite rule that splits an insert into one table into
I had really a simple site written in PHP that I have just rewritten

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.