.htaccess 漂亮的网址

bihw5rsg  于 2023-03-03  发布在  其他
关注(0)|答案(2)|浏览(136)

我正在尝试将页面从www.example.com重定向mysite.com/page1?id=37773到mysite.com/page1/37773。
我尝试在各种博客上搜索,我发现他们尝试与php文件,但即使当我复制和重写它不会工作,所以我在这里得到帮助的exprets。
到目前为止我所尝试的

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]
RewriteRule ^page1/([a-zA-Z_-]+)\.html$ page?id=$1
uoifb46i

uoifb46i1#

你可以试试这个:

RewriteEngine ON
##External redirect rules here.
RewriteCond %{THE_REQUEST} mysite/page1\?id=(\S+)\s
RewriteRule ^ mysite/page1/%1? [R=301,L]

##Internal rewrite rules here...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^mysite/page1/([^/]+)/?$  mysite/page1?id=$1 [NC,QSA,L]
isr3a4wc

isr3a4wc2#

我所做的:-

RewriteEngine ON
RewriteRule ^file/([^/]+) $file.html?id=$1 [L,QSA] #displays mysite.com/file/29829 on browser while the request would be mysite.com/file?id=29829

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]

相关问题