php - How to rewrite the rule in .htaccess to specific url
问题描述
Normally when load the URL http://www.example.com/ it goes to http://www.example.com/index.php.
I have to rewrite the url http://www.example.com/something into http://www.example.com/index.php/something
RewriteEngine on
RewriteRule ^([a-z0-9\.]+) http://www.example.com/index.php/$1 [NC]
causes loop
解决方案
发生该循环是因为您没有将目标排除在外,index
因此Rewriterule
您重定向到 index 然后一次又一次地重定向。
让它像这样:
RewriteEngine on
RewriteRule !^(index|$) index.php%{REQUEST_URI} [L]
那是在内部将请求重定向/something
到/index.php/something
,如果您需要在外部重定向它,请告诉我相应地进行更改。
推荐阅读
- python - 为什么我的代码(应该放在列标题中)将整个 Excel 工作表擦除为空白而没有标题?
- html - 在 h 标签或 p 标签中间设置文本样式的最佳方法是什么?
- python - 列出 Flask Cache 中所有缓存的键
- python - 仅使用数据集的第一个样本进行训练的模型
- c++ - 不允许抽象类类型“mazeGenerator”的 C++ 对象:纯虚函数“olcGameEngine::OnUserUpdate”没有覆盖器
- html - 在语义 UI 中,如何在单击下拉菜单时将用户重定向到新页面,并在单击箭头时显示下拉项目?
- firebase - 颤动 multi_image_picker 图像选择重复
- python - 根据单元格和列名更改数据框中的值
- ruby - RSpec 模拟具有嵌套属性的类
- laravel - Laravel 8 Inertia HighCharts 未在 app.js 中导入