如何在RewriteCond中获取本地路径?

时间:2022-10-06 10:04:04

This is my .htaccess file:

这是我的.htaccess文件:

RewriteEngine On

RewriteBase /projs/CodeIgniterTest

RewriteCond %{REQUEST_URI} !^/projs/CodeIgniterTest/index.php
RewriteRule ^(.*)$ index.php/$0

The RewriteRule works correctly, but I can't get the RewriteCond line to work with a local path. I want this to work:

RewriteRule工作正常,但我不能让RewriteCond行使用本地路径。我想要这个工作:

RewriteCond %{REQUEST_URI} !^index.php

But alas %{REQUEST_URI} doesn't care much about the RewriteBase line and uses the full path. Is there any way to achieve my desired result? I don't want to have to edit the .htaccess file every time I change the project path.

但是唉%{REQUEST_URI}并不关心RewriteBase行并使用完整路径。有没有办法达到我想要的结果?我不想每次更改项目路径时都要编辑.htaccess文件。

1 个解决方案

#1


3  

RewriteRule ^index.php - [L]
RewriteRule ^(.*)$ index.php/$0

Or just

RewriteCond $0 !^index.php
RewriteRule ^(.*)$ index.php/$0

#1


3  

RewriteRule ^index.php - [L]
RewriteRule ^(.*)$ index.php/$0

Or just

RewriteCond $0 !^index.php
RewriteRule ^(.*)$ index.php/$0