它是好有一个很长的.htaccess文件? [英] Is it okay to have a very long .htaccess file?

查看:200
本文介绍了它是好有一个很长的.htaccess文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我给了网址的人在网站上,实际上指向丑恶的东西(在同一网站)。

I am giving out URLs to people on a website, that actually point to something ugly (on the same website).

http://www.mydomain.com/cool-URL
实际指向的
http://www.mydomain.com/boring.php?id=478547&sessid=34734asdf7&otherboringdetails

http://www.mydomain.com/cool-URL
actually points to
http://www.mydomain.com/boring.php?id=478547&sessid=34734asdf7&otherboringdetails

我打算每当需要修改.htaccess文件来实现这一目标。我打算让PHP脚本写.htaccess文件,添加一个新的重写规则,每当有一个新的手出了网址(从管理区域的非程序员可以控制[指定URL的标题为这个新条目,管理:它会自动地分配])

I'm planning to achieve this by modifying the .htaccess file whenever needed. I'm going to make the PHP script write to the .htaccess file, adding a new rewrite rule whenever there is a new hand-out of a url (from an admin area a non-programmer can control [specify the URL title for this new entry, admin : it will be assigned automagically]).

难道这会是一个问题,特别是在1000左右,这样的网址?什么是可以接受的实际数目?因为,我能想象这样的:服务器收到一个URL请求,那么它会搜索.htaccess文件的右侧页面此URL,并最终将用户到正确的页面。如果这是像数据库搜索任何东西,它可能需要很长的时间,为用户真正得到正确的网页...

Is this going to be a problem, especially after 1000 or so such URLs? What is the actual number that is acceptable? Because, I can picture this: the server receives a request for a URL, then it searches the .htaccess file for the right page for this url, and finally sends the user to the right page. If this is anything like Database searching, it might take a long time for the user to actually get to the right page...

在这个任何指针吗?

推荐答案

不,这也不行,并会妨碍你的页面加载速度。

.htaccess文件是在每个服务器上请求进行了评价。即使对于静态图像,CSS和JS文件。所以,你问的网络服务器来解析1000+长可能正则表达式行,同时执行一个请求。

.htaccess files are evaluated on EVERY server request. Even for static images, CSS and JS files. So, you're asking the webserver to parse 1000+ long possibly REGEX lines while executing a request.

此外,父目录的.htaccess文件被处理为居住在子目录过的文件。所以,如果你大量的.htaccess在网站根目录下,然后将处理在子目录中取得的文件太(连同子目录中的.htaccess文件)中的所有请求。

Also, parent directory's .htaccess file is processed for files residing in subdirectory too. So, if your large .htaccess is in root directory of website, then it will be processed for all requests made for files in the subdirectories too (along with the .htaccess file in subdirectory).

这是我的朋友是一个很大的处理。如果你有10幅图像(例如)页它得到处理的11倍。和文件中的多个处理,则更多的周期需要。所以,是的,在一个htaccess文件有任何影响。现在是影响显着?这是很难当它成为一个问题的话。但它必须是pretty的大作为相对简单的处理,而你的情况是。

That my friend is a lot of processing. If you have a page with 10 images (for example) it gets processes 11 times. And the more processing in the file, then the more cycles it takes. So yes, anything in a htaccess file has an impact. Now is that impact noticeable? It is hard to say when it becomes an issue. But it would have to be pretty big as the processing in relatively simple, which in your case is.

有一个htaccess文件,关键是让聪明。你不会希望列出200项。你可以因此聪明的,只需几行(如果你想使用htaccess的)。

The key with an htaccess file is to make it smart. You would not want to list 200 entries. You can so it smart with just a few lines (if you want to use htaccess).

这篇关于它是好有一个很长的.htaccess文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆