user1052448
user1052448

Reputation: 433

.htaccess (Dynamic Directory)

I need help writing this htaccess file.

I have a custom blog and I want pretty URL's like http://www.domain.com/YYYY/MM/DD/blog-title

to call http://www.domain.com/archive/?date=YYYY-MM-DD&title=blog-title

Then I can use PHP and MySQL to display the article. However, I do have other php files in the / directory. I think I Need to exclude those as well, correct?

Upvotes: 1

Views: 159

Answers (2)

Peter
Peter

Reputation: 16943

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/(.+)$ archive/index.php?date=$1-$2-$3&title=$4

Upvotes: 3

user142162
user142162

Reputation:

RewriteEngine on
RewriteRule ^(\d{4})/(\d{1,2})/(\d{1,2})/([^/]+)/?$ /archive/?date=$1-$2-$3&title=$4 [QSA]

Upvotes: 1

Related Questions