2

How do i make it so this:

www.example.com/product

Will point to this file: /product.php but this:

www.example.com/product/thing.php

Will point to this directory: /product/thing.php

I have these rewrite rules in my .htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

It's making this:

www.example.com/product.php

Into this:

www.example.com/product
hjpotter92
  • 78,589
  • 36
  • 144
  • 183
Da_programmer
  • 177
  • 1
  • 15

2 Answers2

4

Toggle the DirectorySlash to Off.

DirectorySlash Off
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.php [NC,L]
hjpotter92
  • 78,589
  • 36
  • 144
  • 183
0

I found out you can do something else that is almost as good.

www.example.com/product

becomes:

www.example.com/product/

If you add a 'index.php' or 'index.html' in the product directory on the web server. So the path becomes product/index.php, and the url will look like this:

www.example.com/product/
Da_programmer
  • 177
  • 1
  • 15