mod_rewrite 的安全替代方案
大家好,在经历了数小时的 mod_rewrite
挫败感并阅读了大量文章之后,我想问这个问题 关于它的问题 stackoverflow 因为我尝试了一切,但它对我不起作用。我不知道为什么,但我已经受够了,所以我寻找替代方案,今天在这里征求意见。我想出了以下方法。方法
首先假设我有这个 URL
http://www.domain.com/articles/6
,并且有一个 articles.php
页面,该页面将从该 URL 获取 ID 并提取文章 来自数据库的内容(mod_rewrite
在这里失败),所以这是一个小解决方案:
$article_id=explode("/",$_SERVER["REQUEST_URI"]);
show_article($article_id[3]);
show_article()
函数将简单地获取 id 并在数据库中查询文章内容我读到服务器不会理解文章是一个 php 页面,所以也有一个小解决方案,
<FilesMatch "^articles$">
< ForceType application/x-httpd-php >
</FilesMatch>
所以有两个问题:
1-这个解决方案会影响搜索引擎蜘蛛对我的网站页面进行索引吗?
2-这是一个好的解决方案还是 mod_rewrite
更好?
注意:很抱歉,如果问题没有被格式化,我的格式不好,如果你能让它看起来更好,我会很感激,真的很抱歉
Hi guys just want to ask this after hours of mod_rewrite
frustration and reading tons of
questions about it on stackoverflow because i tried everything and it didn't work with me. I don't know why, but i had enough so i searched about alternative and am asking here today for opinions. I came up with the following method.method
First assume I have this URL
http://www.domain.com/articles/6
and I have a articles.php
page that will take the ID from this URL and pull the article
content from the database (mod_rewrite
fails in here), so this is a little solution:
$article_id=explode("/",$_SERVER["REQUEST_URI"]);
show_article($article_id[3]);
the show_article()
function will simply take the id and query the database for the article content and I read that the server will not understand that articles is a php page so a little solution too
<FilesMatch "^articles$">
< ForceType application/x-httpd-php >
</FilesMatch>
so two questions :
1- will this solution affect indexing my website pages from search engines spiders ?
2- is this a good solution or mod_rewrite
is better?
Note:am sorry if the question not will formatted am not good in formatting if you can make it look better i will appreciate it really sorry
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要放弃 mod_rewrite,它有点不直观,但是非常强大且有用的软件!在有关 URL 操作的应用程序中,您永远不会得到如此干净的解决方案。对于您的问题:
1)不,它不会影响索引。您的解决方案和涉及
mod_rewrite
的解决方案对于网络蜘蛛来说都是透明的,2)
mod_rewrite
肯定更好,我建议您就
mod_rewrite< 的问题提出问题/code> 没有做你想做的事。我很确定你会和某人一起解决这个问题。
Don't give up with
mod_rewrite
, it's a bit non-intuitive but VERY powerful and useful piece of software! You'll never get so clean solution in application regarding URL manipulation. To your question:1) no, it'll not affect indexing. Both your solution and the one involving
mod_rewrite
are for web spiders transparent,2)
mod_rewrite
is definitely betterI do recommend you to ask question regarding your problems with
mod_rewrite
not doing what you want. I'm pretty sure you'll sort it out with someone.