开发者

mod_rewrite URL rewriting with or without Slash

开发者 https://www.devze.com 2023-01-11 03:29 出处:网络
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

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


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


RewriteRule ^about/?$ /about_us.php
0

精彩评论

暂无评论...
验证码 换一张
取 消