Php Apache mod_重写干净的URL
我在PHP上使用CodeIgniter,它生成以下URL:Php Apache mod_重写干净的URL,php,apache,codeigniter,mod-rewrite,Php,Apache,Codeigniter,Mod Rewrite,我在PHP上使用CodeIgniter,它生成以下URL: http://my.domain.com/app/index.php?/admin/main/ /index.php?是多余的,因此我使用以下重写规则成功地将其删除: RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ ./index.php/$1 [L] 但是,我还想删除/app部分,但是当我这样做时,我得到一个500错误。这与代码点火器有关吗?或
http://my.domain.com/app/index.php?/admin/main/
/index.php?
是多余的,因此我使用以下重写规则成功地将其删除:
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ ./index.php/$1 [L]
但是,我还想删除/app
部分,但是当我这样做时,我得到一个500错误。这与代码点火器有关吗?或者我如何正确地重写此规则(如果可能)?我尝试了以下方法:
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ ./app\/index.php/$1 [L]
谢谢 尝试添加rewritebase
rewritebase/Path/to/directory/directoryblowapps/
对不起,如果htaccess位于项目的主目录中,那么编写htaccess for CI是一种非常古老的方法,只需使用下面的通用htaccess代码(这不需要排除目录,例如旧目录)
RewriteCond $1 !^(index\.php|images|robots\.txt)
所以它也更好,就像我说的那样(通用)
*它不会解决您的目录问题,但这是CI处理index.php删除的最佳方式,而无需在每次添加文档文件夹或其他内容时返回
访问权限:
# Customized error messages.
ErrorDocument 404 /index.php
# Set the default handler.
DirectoryIndex index.php
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
#自定义错误消息。
ErrorDocument 404/index.php
#设置默认处理程序。
DirectoryIndex.php
#各种重写规则。
重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php/$1[L,QSA]
这是在virtualhost配置文件中重写还是在.htaccess文件中重写?这是在.htaccess文件中重写。是否应将其移动到主配置?我有权访问该框。