Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 重写不在根目录中的URL_Php_.htaccess_Web - Fatal编程技术网

Php 重写不在根目录中的URL

Php 重写不在根目录中的URL,php,.htaccess,web,Php,.htaccess,Web,这就是我目前所拥有的,它并没有像我所希望的那样发挥作用: RewriteEngine On RewriteRule ^(.*)$ /index.php?id=$1/ [L] RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC] RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} ^www\. [NC] RewriteRule ^ https://example.com%{REQUEST

这就是我目前所拥有的,它并没有像我所希望的那样发挥作用:

RewriteEngine On
RewriteRule ^(.*)$ /index.php?id=$1/ [L]

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L,NE]
基本上,我想在任何地方删除index.php,并在目录中编辑查询字符串,如下所示:

https://example.com/directory/?id=Test
应该是:

https://example.com/directory/Test/

这可能吗?

您需要使用RewriteBase指令

我让它在这里为你工作:

以下是我的.htaccess中的内容:

RewriteEngine On
RewriteBase /~in9352/directory/
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/?id=$1 [L]
显然,您不需要~in9352

以下是文档: