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 6472249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:19:18+00:00 2026-05-25T06:19:18+00:00

If this is my actual URL to a file: http://www.example.org/posts.php?post=example-post-name In my .htaccess file,

  • 0

If this is my actual URL to a file:

http://www.example.org/posts.php?post=example-post-name

In my .htaccess file, how can I use a regular expression to get to this path when a user submits:

http://www.example.org/posts/example-post-name

So far I’ve come up with this bringing together a few examples (this also included a www redirect):

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*) http://%1/$1 [R=301,L]

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

RewriteRule (.*) /$1.php [L]
RewriteRule ^posts/([A-Za-z])/$ /posts.php?post=$1

But I’m not having much luck with it, can anyone tell me where I’m going wrong?

  • 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-25T06:19:18+00:00Added an answer on May 25, 2026 at 6:19 am

    You need a + after your A-Za-z group to indicate one or more characters, and also you need to add a - to the end of that group. At the end, the /? indicates that the final slash may or may not be present.

    Finally, add [L] to be sure no further rewrite rules get processed.

    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
    RewriteRule ^(.*) http://%1/$1 [R=301,L]
    
    # First rewrite the posts:
    RewriteRule ^posts/([A-Za-z-]+)/?$ /posts.php?post=$1 [L]
    
    # ing0 edit: add in dirs that need changing back.
    # (I dont know if there is an easier way to do this).
    RewriteRule ^posts/css/(.*)$ /css/$1 [L]
    RewriteRule ^posts/img/(.*)$ /img/$1 [L]
    # etc
    
    # Then, if it's not a real file and doesn't already end in .php
    # Note change here ...
    RewriteCond %{REQUEST_URI} !\.php$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # redirect it to PHP.
    RewriteRule (.*) /$1.php [L]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know in an actual query, you can use auto_increment=1 but how is this
Is there a .htaccess script I can use to redirect the url of an
This question is about organizing the actual CSS directives themselves within a .css file.
I'm wondering what the actual reason is why you can do this on a
For the following code in an iPad application: NSString *urlString = @http://www.domain.com/file.xml; ASIHTTPRequest *request
I am following this routing tutorial for Ruby on Rails: http://guides.rubyonrails.org/routing.html It says that
I'm trying to route a path like this: http://www.wikipediamaze.com/wiki/Washington,_D.C. The routing framework is not
I use .htaccess to display my 404 page, while showing the requested URL in
Node's HTTP module is not returning all the expected data from this URL: http://itradedata.co.za/pmchart/prices/GetPricesTRI.asp?Shortname=ACE&numprices=5
This is the actual error message i'm getting if i run it on an

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.