[英]htaccess redirect rule from www.domain.com/?page=news to www.domain.com/news
i need to redirect the URL as 我需要将URL重定向为
www.domain.com/?page=news --> www.domain.com/news www.domain.com/?page=news-> www.domain.com/news
Here my htaccess file: 这是我的htaccess文件:
Options -Multiviews
RewriteEngine On
RewriteBase /
# Force search engines to use www.domain.com
RewriteCond %{HTTP_HOST} !^www\.domain\.com$
RewriteRule ^(.*) http://www.domain.com/$1 [R=301,L]
# Specify search friendly URLs
RewriteRule ^http://www\.domain\.com/news/$ /http://www.domain.com/?page=news [L]
Please suggest me the exact rule to use in .htaccess file. 请建议我在.htaccess文件中使用的确切规则。
Thanks in advance. 提前致谢。
Sorry, I do not know a thing about this, but I have seen a good tutorial posted by someone I am following on facebook: http://www.9lessons.info/2013/11/htaccess-file-tutorial-and-tips.html 抱歉,我对此一无所知,但我在Facebook上看到了我关注的某人发布的一篇不错的教程: http : //www.9lessons.info/2013/11/htaccess-file-tutorial-and-tips html的
Hope this helps. 希望这可以帮助。
Your 2nd rule is not correct as you can't match domain name in RewriteRule
pattern. 您的第二条规则不正确,因为您无法在RewriteRule
模式中匹配域名。 That pattern only matches REQUEST_URI without domain name and query string. 该模式仅匹配REQUEST_URI,不包含域名和查询字符串。
Your 2nd rule should be like this: 您的第二条规则应如下所示:
RewriteCond %{THE_REQUEST} \s/+\?page=([^&\s]+) [NC]
RewriteRule ^ /%1? [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
# Specify search friendly URLs
RewriteCond %{QUERY_STRING} !(^|&)page=[^&]+
RewriteRule ^([^/]+)/?$ /?page=$1 [L,NC,QSA]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.