I must be missing something obvious, since this seems like it shouldn't be a difficult problem. I want all url paths on my site (http://example.com
, http://example.com/admin
, http://example.com/happy/happy/joy/joy
, etc.) to be handled through my index.php. I've seen this done before, but offhand I do not know how to do it.
使用index.php管理我站点中的所有url路径
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- dongyun7897 2011-10-31 01:12关注
Just create an
.htaccess
file in your root directory with this :# Turn on URL rewriting RewriteEngine On # Base directory RewriteBase / # Protect hidden files from being viewed <Files .*> Order Deny,Allow Deny From All </Files> # Allow any files or directories that exist to be displayed directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Rewrite all other URLs to index.php/URL RewriteRule .* index.php/$0 [PT]
Apache flags explained :
[L]
- Alias for "Last", instructs the server that the rewrite rules have come to an end and it's time to perform an internal redirection without changing the browser's uri.[PT]
- Alias for "Pass Through", allows a Mod_Rewrite manipulated uri to be passed to the next type of handler, accordingly to the php.ini module's order of inclusion. Usefull depending on the subject.本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 C#读写EXCEL文件,不同编译
- ¥15 如何提取csv文件中需要的列,将其整合为一篇完整文档,并进行jieba分词(语言-python)
- ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
- ¥15 扩散模型sd.webui使用时报错“Nonetype”
- ¥15 stm32流水灯+呼吸灯+外部中断按键
- ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
- ¥15 NX MCD仿真与博途通讯不了啥情况
- ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
- ¥15 gradio的web端页面格式不对的问题
- ¥15 求大家看看Nonce如何配置