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
以下是文档: