.htaccess正确写入url重写页面,没有后缀

时间:2021-08-06 11:18:56

I would like to set the .htaccess

我想设置.htaccess

ORIGINAL
www.foo.com/bar/index.php?op=find

SHOULD BECOME
www.foo.com/bar/find/

I tried in this way but i think there is something wrong because the url does not change

我试过这种方式,但我认为有一些错误,因为网址没有改变

Options +FollowSymLinks

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^bar/find/$ /bar/index.php?op=find [L]

How can I set it? Thank you

我怎么设置它?谢谢

1 个解决方案

#1


You can add a new rule for redirecting to pretty URL:

您可以添加新规则以重定向到漂亮的URL:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{THE_REQUEST} /(bar)/index\?op=([^\s&]+) [NC]
RewriteRule ^ /%1/%2? [R=302,L,NE]

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

#1


You can add a new rule for redirecting to pretty URL:

您可以添加新规则以重定向到漂亮的URL:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{THE_REQUEST} /(bar)/index\?op=([^\s&]+) [NC]
RewriteRule ^ /%1/%2? [R=302,L,NE]

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