简体   繁体   中英

.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?

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM