Web Analytics Made Easy -
StatCounter I need some help with .htaccess rewriting... - CodingForum

Announcement

Collapse
No announcement yet.

I need some help with .htaccess rewriting...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • I need some help with .htaccess rewriting...

    Hey,

    I'm trying to make a .htaccess file for my new site.

    the first thing I want my .htaccess to do is to change my .php extension into a /. Like so:

    Code:
    http://www.example.com/about.php
    
    to
    
    http://www.example.com/about/
    Then, I want it's sub sections to be created logically. Like so:

    Code:
    http://www.example.com/about-section.php
    
    to
    
    http://www.example.com/about/section/
    How do I do this in my .htaccess file?

  • #2
    Change the URL's on your site to look like what you want them to be, then do something along the lines of...

    Code:
    RewriteCond %{REQUEST_URI} !-f
    RewriteCond %{REQUEST_URI} !-d
    RewriteRule ^([^/])/?$ /$1.php [L]
    
    RewriteCond %{REQUEST_URI} !-f
    RewriteCond %{REQUEST_URI} !-d
    RewriteRule ^([^/])/([^/])/?$ /$1-$2.php [L]

    Comment


    • #3
      That code doesn't seem to work at all

      Comment

      Working...
      X
      😀
      🥰
      🤢
      😎
      😡
      👍
      👎