Php mod_rewrite删除查询字符串的名称
我的URL有一个大问题。我知道如何删除index.php表单url,但问题是我不知道如何从url中删除“?act=” 我现在的链接是http://localhost/doctor/public/?act=test,我想像http://localhost/doctor/public/test一样创建它 我当前的.htaccess文件放在公用文件夹中中:Php mod_rewrite删除查询字符串的名称,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,我的URL有一个大问题。我知道如何删除index.php表单url,但问题是我不知道如何从url中删除“?act=” 我现在的链接是http://localhost/doctor/public/?act=test,我想像http://localhost/doctor/public/test一样创建它 我当前的.htaccess文件放在公用文件夹中中: <IfModule mod_rewrite.c> RewriteEngine On # Remove
<IfModule mod_rewrite.c>
RewriteEngine On
# Removes index.php from ExpressionEngine URLs
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
重新启动发动机
#从ExpressionEngine URL中删除index.php
重写秒$1!\。(gif | jpe?g | png)$[NC]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php/$1[L]
我需要有关如何执行此操作的帮助。在表达式引擎规则之前,您可以添加:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /doctrine/public/?act=$1 [L]
将请求(如http://localhost/doctor/public/test)内部重写为/doctor/public/?act=test
。您需要确保内容中的链接看起来像/doctor/public/test
,而不是带有查询字符串的链接。如果有超出您控制范围的链接(如谷歌索引页面),您可以添加以下内容:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /doctrine/public/?\?act=([^&\ ]+)
Rewrite Rule ^ /doctrine/public/%1? [L,R=301]
将浏览器指向不带查询字符串的URL
很遗憾,这与您的表达式引擎URL不兼容。请使用以下代码:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /doctrine/
RewriteRule ^(public)/([^/]+)/?$ $1/?act=$2 [L,QSA,NC]
# Removes index.php from ExpressionEngine URLs
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
重新启动发动机
重写基础/原则/
重写规则^(公共)/([^/]+)/?$$1/?act=$2[L,QSA,NC]
#从ExpressionEngine URL中删除index.php
重写秒$1!\。(gif | jpe?g | png)$[NC]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php/$1[L]