我需要它,所以当我转到mydomainname.com/page/week1
时,它会显示mydomainname.com/page.php?month=week1
。我的代码会这样做吗?
rewriteengine on
rewritecond %{HTTP_HOST} ^www.mydomianname.com$ [OR]
rewritecond %{HTTP_HOST} ^mydomianname.com$
rewriterule ^mydomianname\.com/page/?([-A-Za-z0-9]+)/?$ "http\:\/\/mydomianname\.com\/page\.php?month=$1" [L]
当我去mydomainame.com/page/week1
时,我得到了
在此服务器上找不到请求的URL / page / week1。
我当前的http访问
rewriteengine on
rewritecond %{HTTP_HOST} ^www.fetustobaby.com$ [OR]
rewritecond %{HTTP_HOST} ^fetustobaby.com$
rewriterule ^fetustobaby\.com\/page\/([-A-Za-z0-9]*)\/?$ page.php?month=$1 [L]
答案 0 :(得分:0)
您的代码存在一些问题,例如RewriteRule仅匹配URL和主机名匹配不属于RewriteRule。以下是您可以在.htaccess中使用的固定代码:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?mydomianname\.com$ [NC]
RewriteRule ^page/([^/]+)/?$ /page.php?month=$1 [L,NC,QSA]