我是设置.htaccess的新手,我希望在我的问题上有所帮助。
如果用户点击以下URL(原始URL):
http://www.example.com/somepage/something
我希望它redirect到:
.htaccessredirect性能
OpenShift,Python 2.7和静态文件与htaccess
我怎样才能禁用一个子类别的RewriteRule?
使用Mod_Rewrite将ROOT重写为另一个path
在.htaccess文件中validationGooglebot
http://www.example.com/somepage
并保留在浏览器中的原始url。
到目前为止,我有以下几点:
RewriteRule ^somepage/(.*)$ /somepage [R=301]
但是,它不工作。
我如何得到这个工作?
编辑:
这是我的.htaccess文件现在看起来像:
# do not allow anyone else to read your .htaccess file <Files .htaccess> deny from all </Files> # forbid viewing of directories Options All -Indexes # hide this list of files from being seen when listing a directory IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti* # disable the server signature- helps with preformance ServerSignature Off RewriteEngine On #example.com/page will display the contents of example.com/page.html RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.html -f RewriteRule ^(.+)$ $1.html [L,QSA] #301 from example.com/page.html to example.com/page RewriteCond %{THE_REQUEST} ^[AZ]{3,9} /.*.html HTTP/ RewriteRule ^(.*).html$ /$1 [R=301,L] RewriteRule ^somepage/(.*)$ /somepage [R=301]
mod_rewrite – 添加www
.htaccess平面链接的重写规则
漂亮的Nginx中的平均值应用程序的url
请求的资源.htaccess上不存在Access-Control-Allow-Origin标头
.htaccess重写正则expression式:匹配除“索引”
这个规则是问题:
RewriteRule ^somepage/(.*)$ /somepage [R=301]
有两个原因:
由于您不希望URL更改,因此在此规则中不得使用R=301标志。
更大的问题是,你的正则表达式^somepage/(.*)$也将匹配/somepage/和你需要匹配/somepage/something 。
要解决这个问题有你的完整的.htaccess像这样:
# do not allow anyone else to read your .htaccess file <Files .htaccess> deny from all </Files> # forbid viewing of directories Options All -Indexes # hide this list of files from being seen when listing a directory IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti* # disable the server signature- helps with preformance serverSignature Off RewriteEngine On RewriteBase / #301 from example.com/page.html to example.com/page RewriteCond %{THE_REQUEST} ^[AZ]{3,9} /.*.html HTTP/ [NC] RewriteRule ^(.+?).html$ /$1 [R=301,L] RewriteCond %{DOCUMENT_ROOT}/$1.html -f [NC] RewriteRule ^([^/.]+) $1.html [L]
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。