.htaccess 使用我的域中的代码重写UrL

.htaccess 使用我的域中的代码重写UrL,.htaccess,.htaccess,URL:http://domainname.com/index.php?p=top-游戏 我需要将其重写为http://domainname.com/top-games 如何使用htaccess文件执行此操作?请任何人给我密码 谢谢试试这个: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}

URL:
http://domainname.com/index.php?p=top-游戏

我需要将其重写为
http://domainname.com/top-games

如何使用htaccess文件执行此操作?请任何人给我密码

谢谢

试试这个:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^(.*)$ index.php?p=$1 [QSA,L]
</IfModule

重新启动发动机
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^(.*)$index.php?p=$1[QSA,L]

您可能正在寻找反向重定向

将此代码放入
文档\u ROOT/.htaccess
文件:

RewriteEngine On

# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php\?p=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=302,L]

# internal forward from pretty URL to actual one
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/?$ /index.php?q=$1 [L,QSA]

htaccess不会重定向,它用于按照您的意愿重写URL。当您运行时,内部URL将被考虑如下