Simple rewrite question

basically what I am trying to do is rewrite localhost/app/test/create.php to localhost/app/test/create/ which I am capable of doing with the last line of my htaccess but it’s not working for me. So obviously I missing something important here :nono:

So my htaccess looks like this.

RewriteEngine On
RewriteBase /app/
RewriteRule ^index\\.php(.*)$ $1 [R,L,QSA]
RewriteRule ^(.*)/index\\.php$ $1/ [R,L]
//this next line does kind of what I want to do... but I get Not Found instead of the page being served.
RewriteRule ^(.*)/(.*)\\.php$ $1/$2/ [R,L]

Try this code :

RewriteEngine On

# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ localhost/app/test/create/$1 [R=301,L]

# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\\.php([#?][^\\ ]*)?\\ HTTP/
RewriteRule ^(.+)\\.php$ localhost/app/test/$1 [R=301,L]

# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]

rob,

You’re going in the wrong direction! YOU must create the non-servable URI then write mod_rewrite code to redirect to something Apache can serve.

You might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It’s helped may members and should help you, too.

Regards,

DK

Wow, thanks a ton. Your site brings nostalgic memories of the 90’s :slight_smile: I love it.

Rob,

I’ll assume that means that the page is too long. I know that (and I’m always trying to prevent the necessity of scrolling) but that was done in case someone wanted to download the whole enchalada (I hate docs spread over many pages).

In any event, I hope it helped.

Regards,

DK