user3183915 user3183915 - 4 months ago 19
PHP Question

htaccess clean urls with with sub folder

I'm trying to create clean urls on my gallery website.

<http://sloanegalleryofart.com>


I was able to clean up general navigation. However, run in some hardcore difficulties while trying to configure sub folders

Curretnly my htaccess looks like so

Options +FollowSymLinks
RewriteEngine on

RewriteBase /

RewriteCond %{HTTP_HOST} ^sloanegalleryofart.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.sloanegalleryofart.com$
RewriteCond %{REQUEST_URI} !/
RewriteRule (.*) /$1 [L]

RewriteRule ^about/$ /about/about.php
RewriteRule ^contact/$ /contact/contact.php
RewriteRule ^shows/$ /shows/shows.php
RewriteRule ^artists/$ /artists/artists.php
RewriteRule ^books/$ /books/books.php


If I try to navigate from artists page sloanegalleryofart.com/artists to each individual artist it looks like so sloanegalleryofart.com/artists/artist.php?artist=Gleb-Bogomolov

When idealy i want it to be sloanegalleryofart.com/artists/Gleb-Bogomolov/ . Just cut out the whole " artist.php?artist= " out of the url

Thank you in advance !

Answer

This is your solution

RewriteRule ^artists/([0-9a-zA-Z\-]{1,})?/?$ /artists/artists.php?artist=$1

When you access http://sloanegalleryofart.com/artists/Gleb-Bogomolov
you will be seen http://sloanegalleryofart.com/artists/artists.php?artist=Gleb-Bogomolov

Comments