.htaccess-ampersand到问号并删除index.php

.htaccess-ampersand到问号并删除index.php,php,regex,apache,.htaccess,mod-rewrite,Php,Regex,Apache,.htaccess,Mod Rewrite,我想更改url从 到 请帮帮我 我有权访问 DirectoryIndex index.php RewriteEngine On RewriteCond %{REQUEST_URI} !^/index.php RewriteRule ^/([a-z]+)(?:$|\?(?:.+)) /index.php?city=$1 [NC,L,B,QSA,NE] 但它不起作用试试这个规则: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f Rew

我想更改url从 到

请帮帮我

我有权访问

DirectoryIndex index.php

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^/([a-z]+)(?:$|\?(?:.+)) /index.php?city=$1 [NC,L,B,QSA,NE]
但它不起作用

试试这个规则:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/?$ /index.php?city=$1 [L,QSA]
试试这个规则:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/?$ /index.php?city=$1 [L,QSA]
试试这个规则:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/?$ /index.php?city=$1 [L,QSA]
试试这个规则:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/?$ /index.php?city=$1 [L,QSA]
参考资料:

参考资料:

参考资料:


参考资料:

哦,非常非常感谢,请告诉我如果包含字符“-”,请怎么做?对不起,我不明白你的评论。哦,非常感谢,请告诉我如果包含字符“-”,请怎么做?对不起,我不明白你的评论。哦,谢谢,非常非常非常感谢,请告诉我如果包含字符“-”,请怎么做?对不起,我不明白你的评论。哦非常非常感谢。请告诉我如果包含字符“-”如何?对不起,我不明白你的评论。