久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

PHP 是否允許修改當前文件夾中的 .htaccess 文件?

Is PHP allowed to modify .htaccess file in current folder?(PHP 是否允許修改當前文件夾中的 .htaccess 文件?)
本文介紹了PHP 是否允許修改當前文件夾中的 .htaccess 文件?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我在共享主機上有一個 PHP 網絡應用程序.我的目標是在 PHP 頁面運行時從 PHP 代碼修改 .htaccess 文件.我需要 .htaccess 將幾行 mod_rewrite 插入其中.

I have a PHP web app located on shared hosting. My goal is to modify .htaccess file from PHP code when the PHP page is running. I need that .htaccess to insert a couple of mod_rewrite lines into it.

問題是在Windows+Apache上我可以動態修改.htaccess文件但是當我嘗試以任何方式訪問此文件時,Linux 上的相同代碼會報告問題方式(復制或 fopen):

The problem is that on Windows+Apache I can dynamically modify .htaccess file but the same code on Linux reports a problem when I try to access this file in any way (copy or fopen):

無法打開流:權限被拒絕"

我給了 .htaccess 文件 777 權限 - 仍然沒有結果.是什么阻止我這樣做?我該如何制定解決方法?

I have given .htaccess file 777 permissions - still no result. WHat prevents me from doing this? How can I develop a workaround?

附言我最初的目標是能夠在 .htaccess 中添加一個新的 RewriteRule 來映射一個新添加的 category_id 和新的 category_name.

P.S. My initial goal was to be able to add a new RewriteRule into .htaccess that maps a newly added category_id with new category_name.

如果不是共享主機,我會使用 RewriteMap(在主 Apache 配置中)之類的東西,并且能夠訪問地圖文件.

If it wasn't shared hosting, I would use something like RewriteMap (in main Apache config) and would be able to access the map file.

這是我無法使用 PHP+Apache 解決的第一個真正的限制,但我希望它也可以避免.

This is the first real limitation I've been unable to tackle with PHP+Apache, but I hope it's circuventable too.

推薦答案

我想建議其他一些也有效的方法.與其為每個特殊"網址編寫規則,為什么不為所有網址使用一個規則?

I want to suggest something else that also works. Instead of writing a rule for every 'special' url, why not use one for all?

我發現使用 wordpress 使用起來要容易得多:每個 url 都被重定向到索引.

I found it a whole lot easier to use what wordpress uses: every url is redirected to the index.

您所要做的就是設置索引文件,讀取加載的目錄(可能使用 $_SERVER['URI_REQUEST']),然后處理它.

All you have to do is, set up the index file, read in the directory that was loaded (perhaps using $_SERVER['URI_REQUEST']), and deal with it.

添加到.htaccess:

add to .htaccess this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

多虧了那個笨蛋,你才有了一個可以隨意使用的系統.如果您想重命名您的類別 url,或添加另一個特殊情況,它已經準備好了!

Thanks to that chunck you have a system somewhat unlimited at your disposal. If you ever feel like renaming you categrory url, or add another special case, it's already ready!

這篇關于PHP 是否允許修改當前文件夾中的 .htaccess 文件?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Action View Helper in Zend - Work around?(Zend 中的動作視圖助手 - 解決方法?)
Is this a good way to match URI to class/method in PHP for MVC(這是將 URI 與 PHP 中用于 MVC 的類/方法匹配的好方法嗎)
Where do I save partial (views) in Zend Framework, to be accessible for all Views in my App?(我在哪里保存 Zend Framework 中的部分(視圖),以便我的應用程序中的所有視圖都可以訪問?) - IT屋-程序員軟件開發技術
Having a single entry point to a website. Bad? Good? Non-issue?(有一個網站的單一入口點.壞的?好的?沒問題?)
Is MVC + Service Layer common in zend or PHP?(MVC + 服務層在 Zend 或 PHP 中常見嗎?)
Hello World example in MVC approach to PHP(PHP MVC 方法中的 Hello World 示例)
主站蜘蛛池模板: 欧美黑人国产人伦爽爽爽 | 香蕉视频91 | 久久久久精 | 日韩欧美国产一区二区三区 | 麻豆精品国产免费 | 精品久久香蕉国产线看观看亚洲 | 国产91黄色 | 久久精品成人一区 | 日韩成人免费av | 91av视频在线 | 看黄在线 | 99热精品久久| 久久婷婷av| 精品亚洲一区二区三区四区五区高 | 亚洲女人天堂网 | 国产精品99久久久久久久久久久久 | 日韩理论电影在线观看 | 91九色视频 | 亚洲va欧美va天堂v国产综合 | 成人在线h | 91干b| 一区二区电影 | 男人天堂网址 | 国产成人精品一区二区三区视频 | 成人在线观看免费 | 国内精品久久影院 | 久久福利电影 | 欧美一区免费 | 亚洲精品久久久久久一区二区 | 欧美11一13sex性hd | 精品国产一区二区国模嫣然 | 一级免费毛片 | 精品网 | 国产一区二区在线播放视频 | 国产精品999| 日韩av免费在线电影 | 成人在线视频网址 | 欧美大片一区二区 | 九色 在线| 一区在线观看 | 免费一级毛片 |