如何允许 .php、尾部斜杠和无尾部斜杠?
如何允许 .php、尾部斜杠和无尾部斜杠?
RewriteEngine on
RewriteCond %{REQUEST_URI} (.*)(\.php|\/)$
RewriteRule (.*)$ %1 [R=301,L]
DirectoryIndex index.php
#directory ban
Options All -Indexes
ErrorDocument 400 /error.php
ErrorDocument 404 /error.php
ErrorDocument 500 /error.php
FileETag MTime Size
ExpiresActive on
ExpiresDefault "access plus 86400 seconds"
# 1 WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
# 2 DAYS
<FilesMatch "\.(xml|txt|css|js)$">
Header set Cache-Control "max-age=172800, proxy-revalidate"
</FilesMatch>
# 1 MIN
<FilesMatch "\.(html|htm|php)$">
Header set Cache-Control "max-age=60, private, proxy-revalidate"
</FilesMatch>
<IfModule mod_expires.c>
# any Expires Directives go here
</IfModule>
<IfModule mod_headers.c>
# any Header directives go here
</IfModule>
<ifmodule mod_deflate.c="">
<filesmatch ".(js|css)$"="">
SetOutputFilter DEFLATE
</filesmatch>
</ifmodule>
RewriteCond %{HTTP_HOST} !^mydomain\.com$ [NC]
RewriteRule ^(.*)$ mydomain.com/$1 [R=301,L]
How do I allow .php, trailing slash, and no trailing slash?
RewriteEngine on
RewriteCond %{REQUEST_URI} (.*)(\.php|\/)$
RewriteRule (.*)$ %1 [R=301,L]
DirectoryIndex index.php
#directory ban
Options All -Indexes
ErrorDocument 400 /error.php
ErrorDocument 404 /error.php
ErrorDocument 500 /error.php
FileETag MTime Size
ExpiresActive on
ExpiresDefault "access plus 86400 seconds"
# 1 WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
# 2 DAYS
<FilesMatch "\.(xml|txt|css|js)$">
Header set Cache-Control "max-age=172800, proxy-revalidate"
</FilesMatch>
# 1 MIN
<FilesMatch "\.(html|htm|php)$">
Header set Cache-Control "max-age=60, private, proxy-revalidate"
</FilesMatch>
<IfModule mod_expires.c>
# any Expires Directives go here
</IfModule>
<IfModule mod_headers.c>
# any Header directives go here
</IfModule>
<ifmodule mod_deflate.c="">
<filesmatch ".(js|css)$"="">
SetOutputFilter DEFLATE
</filesmatch>
</ifmodule>
RewriteCond %{HTTP_HOST} !^mydomain\.com$ [NC]
RewriteRule ^(.*)$ mydomain.com/$1 [R=301,L]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用这个修改后的 .htaccess 文件:
Try this modified .htaccess file instead:
尝试以下规则,使其根据您的要求工作,
如果它不起作用,请告诉我。
Try below rules to make it work according to your requirement,
Let me know in case it doesnt work..