Diyan Bogdanov
Diyan Bogdanov

Reputation: 77

.htaccess replace question mark

I am trying to replace question mark with slash. lockalhost/work/gallery?album=pirano => lockalhost/work/gallery/piano When I go to lockalhost/work/gallery/piano I get a 500 internal server error. How to fix this Also how to remove .php extension form files. I am using this

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

But is there any better way to do it?

Upvotes: 0

Views: 174

Answers (1)

Jon Lin
Jon Lin

Reputation: 143896

maybe something like this?

RewriteEngine On

RewriteCond %{THE_REQUEST} \ /+work/gallery\?album=([^&\ ]+)
RewriteRule ^ /work/gallery/%1? [L,R]

RewriteCond %{THE_REQUEST} \ /+([^\?\ ]+)\.php
RewriteRUle ^ /%1 [L,R]

RewriteRule ^work/gallery/(.*)$ /work/gallery?album=$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.*)$ /$1.php [NC,L]

Upvotes: 1

Related Questions