htaccess清理网址与子文件夹

时间:2016-07-10 21:09:16

标签: php .htaccess

我正在尝试在我的图库网站上创建干净的网址。

<http://sloanegalleryofart.com>

我能够清理一般导航。但是,在尝试配置子文件夹时遇到一些核心问题

Curretnly我的htaccess看起来像这样

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 

如果我尝试从艺术家页面sloanegalleryofart.com/artists导航到每个艺术家,那么它就像sloanegalleryofart.com/artists/artist.php?artist=Gleb-Bogomolov

理想情况下,我希望它为sloanegalleryofart.com/artists/Gleb-Bogomolov/。只需从网址中删除整个artist.php?artist=

提前谢谢!

1 个答案:

答案 0 :(得分:0)

这是您的解决方案

event

访问时 RewriteRule ^artists/([0-9a-zA-Z\-]{1,})?/?$ /artists/artists.php?artist=$1
你会被看到 http://sloanegalleryofart.com/artists/Gleb-Bogomolov