blue
blue

Reputation: 11

mod_rewrite URL rewriting with or without Slash

What is the correct way to write out the .htacess so that both www.domain.com/about_us and www.domain.com/about_us/ goes to www.domain.com/about_us.php

Currently, what I have is the below and just wonder if there's a way to put it in one line

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(about)$ /about_us.php
RewriteRule ^(about/)$ /about_us.php

Upvotes: 1

Views: 847

Answers (2)

umop
umop

Reputation: 2192

It's a regular expression, so adding ? after the / will make the / optional (0 or 1 occurrences). Also, the parenthesis are unnecessary:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^about/?$ /about_us.php

Upvotes: 3

Artefacto
Artefacto

Reputation: 97845

RewriteRule ^about/?$ /about_us.php

Upvotes: 1

Related Questions