3
这是文件看起来什么我的.htaccess这样的:的.htaccess重定向到整齐URL
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
#removes trailing slash if not a directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=301,L]
#adds ".php" to a URL that isn't a directory or a file
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
RewriteCond %{REQUEST_fileNAME} !-d
RewriteCond %{REQUEST_fileNAME} !-f
RewriteRule (.*) $1.php [L]
虽然它让我访问的网址不带.php到底是为了例如example.com/sign-up
它不会从example.com/sign-up.php
重定向我example.com/sign-up
有,我可以添加到该文件要做到这一点的任何代码?
任何有识之士将是非常有益的
哇!这太棒了!谢谢! –
还有我怎么重定向来自:http://example.com/?slug=hey-there 到:http://example.com/hey-there 请帮@ ansuman,肖汉 –
有什么办法通过它我可以将此重定向仅限于根级别,例如:example.com/sing.php应该重定向到example.com/sing 但这不应该发生在example.com/data/sync.php .. 任何想法@anubhava 感谢您的时间! –