我想要一个带有子目录的网址,而不使用www来重定向到带有www的相同网址

时间:2014-04-12 14:44:50

标签: php regex apache .htaccess mod-rewrite

example.com/category/应重定向到www.example.com/category/

我的.htaccess文件位于下方。

example.com/category/.htaccess

Options +FollowSymLinks
RewriteEngine On
RewriteBase /category/

RewriteRule ^([0-9]+)(?:/[^/]+)?/?$ load.php?cat=$1 [L,QSA]

RewriteRule ^([0-9]+)/[^/]+/[^/]+/([0-9]+)/?$ load.php?cat=$1&p=$2 [L,QSA]

1 个答案:

答案 0 :(得分:1)

RewriteBase行:

下方插入此规则
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,NE,L]
相关问题