简体   繁体   English

htaccess将规则重写为index.php?p = pagename

[英]htaccess rewrite rule to index.php?p=pagename

I am using this htaccess code to create a rewrite rule 我正在使用此htaccess代码创建重写规则

RewriteCond %{HTTP_HOST} ^my\.domain\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.php -f
RewriteRule ^(.*)$ index.php?p=$1.php [L,QSA]

i want to rewrite pages like 我想改写像

http://my.domain.net/index.php?p=tickets/openticket to look like http://my.domain.net/tickets/openticket http://my.domain.net/index.php?p=tickets/openticket看起来像http://my.domain.net/tickets/openticket

but its just showing index.php without the ?p= ... 但它只是显示index.php而没有?p= ...

Try this code as your first rules : 尝试将此代码作为您的第一条规则

RewriteCond %{THE_REQUEST} /index\.php\?p=([^\s&]+) [NC]
RewriteRule ^ %1? [R=302,L]

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

RewriteRule ^(.*)$ index.php?p=$1 [L,QSA] RewriteRule ^(。*)$ index.php?p = $ 1 [L,QSA]

try this. 尝试这个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM