Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
.htaccess Htaccess用于避免index.php?page=来自URL_.htaccess - Fatal编程技术网

.htaccess Htaccess用于避免index.php?page=来自URL

.htaccess Htaccess用于避免index.php?page=来自URL,.htaccess,.htaccess,我的项目有URL,如,等等 我希望避免使用index.php?page=和给定URL中的参数80,并希望将URL更改为和。如何使用htaccess文件实现此目的。尝试将其添加到文档根目录中的htaccess文件: RewriteEngine On RewriteCond %{THE_REQUEST} \ /index\.php\?([^\ ]*) RewriteRule ^ /%1 [L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteCo

我的项目有URL,如,等等


我希望避免使用index.php?page=和给定URL中的参数80,并希望将URL更改为和。如何使用htaccess文件实现此目的。

尝试将其添加到文档根目录中的htaccess文件:

RewriteEngine On

RewriteCond %{THE_REQUEST} \ /index\.php\?([^\ ]*)
RewriteRule ^ /%1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L,QSA]

通过
httpd.conf
启用
mod_rewrite
.htaccess
,然后将此代码放入
文档根目录下.htaccess
文件:

RewriteEngine On

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php\?page=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=301,L,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php?page=$1 [L,QSA]