问题描述
我有一个名为 DROP INDEX IF EXISTS user_skills ;
CREATE INDEX user_skills
ON user_table
USING gist (array_to_string(user_skills,' ') gist_trgm_ops) ; -- gin_trgm_ops and gist_trgm_ops indexes are compliant with the LIKE operator and the regular expressions
的文件,并希望通过 .htaccess 生成 url filename-step1.php
。
我当前的 domain.com/filename/step1
文件如下所示:
.htaccess
目前,这适用于从 url 中删除 RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
标记。只需要修复目录。
解决方法
您可以添加一个 RewriteRule
以重定向到 $1/$2.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)$ /$1-$2.php [NC,L]
</IfModule>
因此,filename/step1
将触发 filename-step1.php
文件。
我在这里提供了 2 个解决方案,请一次仅在您的 .htaccess 文件中尝试一个。使用您显示的示例,您能否尝试遵循通用规则。
RewriteEngine ON
RewriteCond %{HTTP_HOST} domain\.com [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/(.*)/?$ $1-$2.php [NC,L]
或者,如果您正在寻找特定的网址 filename/step1
,请尝试关注。
RewriteEngine ON
RewriteCond %{HTTP_HOST} domain\.com [NC]
RewriteRule ^(filename)/(step1)/?$ $1-$2.php [NC,L]