[英]how to code .htaccess file code in a php file
I am trying to add .htaccess
function run in a .php
file. 我试图添加在.php
文件中运行的.htaccess
函数。 Is there any ideas regarding this? 有什么想法吗?
I want convert this htaccess code into my php code. 我想将此htaccess代码转换为我的php代码。 I am trying it for SEO purpose in server there is not access for .htaccess
file so trying to go through same function in php files. 我正在尝试用于服务器中的SEO目的,无法访问.htaccess
文件,因此尝试通过php文件中的相同功能。
# BEGIN Compress text files
<ifModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/xml text/css text/plain
AddOutputFilterByType DEFLATE image/svg+xml application/xhtml+xml application/xml
AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml application/atom+xml
AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript application/json
AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-otf
AddOutputFilterByType DEFLATE font/truetype font/opentype
</ifModule>
# END Compress text files
# BEGIN Expire headers
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 5 seconds"
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 216000 seconds"
ExpiresByType application/javascript "access plus 216000 seconds"
ExpiresByType application/x-javascript "access plus 216000 seconds"
ExpiresByType text/html "access plus 600 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
</ifModule>
# END Expire headers
# BEGIN Cache-Control Headers
<ifModule mod_headers.c>
<filesMatch "\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(css)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(js)$">
Header set Cache-Control "private"
</filesMatch>
<filesMatch "\.(x?html?|php)$">
Header set Cache-Control "private, must-revalidate"
</filesMatch>
</ifModule>
# END Cache-Control Headers
# BEGIN Turn ETags Off
FileETag None
# END Turn ETags Off
there's no magic way to do that. 没有魔术的方法可以做到这一点。 You have to write an algorithm in PHP. 您必须使用PHP编写算法。 You can use urldecode($_SERVER['REQUEST_URI']);
您可以使用urldecode($_SERVER['REQUEST_URI']);
for get the requests and use explode
or split
to parse it. 获取请求并使用explode
或split
进行解析。
By the way, don't forget to set up your server to mod_rewrite. 顺便说一句,不要忘记将服务器设置为mod_rewrite。 Hope it, helps. 希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.