.htaccess htaccessurl重写
我有一个htaccess文件,它将所有请求重定向到index.php 重写cond%{REQUEST_FILENAME}-d 重写cond%{REQUEST_FILENAME}-f 重写规则。*./index.php 我的问题是我想重定向到一个不存在的文件夹,它不应该影响当前htaccess重定向到index.php。因为它链接到整个网站 例如 domain.com/search=kannan&id=21 到 domain.com/kannan.htaccess htaccessurl重写,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我有一个htaccess文件,它将所有请求重定向到index.php 重写cond%{REQUEST_FILENAME}-d 重写cond%{REQUEST_FILENAME}-f 重写规则。*./index.php 我的问题是我想重定向到一个不存在的文件夹,它不应该影响当前htaccess重定向到index.php。因为它链接到整个网站 例如 domain.com/search=kannan&id=21 到 domain.com/kannan <IfModule mod_rewrite.
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /public/$1
#RewriteRule ^ index.php [L]
</IfModule>
我只需要一种方法,只允许此请求,其他所有内容都转到index.php,任何想法…您可以使用一个条件来捕获与特定模式匹配的请求,如: 重写cond%{REQUEST_URI}^domain.com/search(+)$
然后重写。或者:您可以使用条件捕获与特定模式匹配的请求,如: 重写cond%{REQUEST_URI}^domain.com/search(+)$
然后重写。或者:我建议您通过表单传递id。意味着使用Form post方法传递id,然后您只需要在url中包含“domain.com/kannan”,id将作为post传递 使用类似类型的代码,如下所示-
<form method="post" action="domain.com/kannan">
<input type="hidden" value="21" name="id" />
</form>
通过这种方式,表单将以id=21发布到domain.com/kannan,url将为domain.com/kannan我建议您通过表单传递id。意味着使用Form post方法传递id,然后您只需要在url中包含“domain.com/kannan”,id将作为post传递
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /public/$1
#RewriteRule ^ index.php [L]
</IfModule>
使用类似类型的代码,如下所示-
<form method="post" action="domain.com/kannan">
<input type="hidden" value="21" name="id" />
</form>
通过这种方式,表单将以id=21发布到domain.com/kannan,url将为domain.com/kannan
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /public/$1
#RewriteRule ^ index.php [L]
</IfModule>
选项+FollowSymLinks
重新启动发动机
重写cond%{REQUEST_URI}^/公众/
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^(.*)$/public/$1
#重写规则^index.php[L]
选项+FollowSymLinks
重新启动发动机
重写cond%{REQUEST_URI}^/公众/
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^(.*)$/public/$1
#重写规则^index.php[L]