[英]Unable to write a rewrite rule in .htaccess for my php website
我的网站是v2.example.com,我正在尝试编写.htaccess规则,但无法使用.htaccess。
我想要这个:v2.example.com/ABCDEFGH
我希望将值ABCDEFGH作为参数,例如v2.example.com/index.php?id=ABCDEFGH
任何人都可以帮我解决这个问题。
我试过这个:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*) index.php?id=$1 [L]
</IfModule>
请帮我。
RewriteEngine on
RewriteRule ^(.*)$ index.php?id=$1 [L,QSA]
当它进入无限循环时会崩溃,因为index.php被进一步重写为index.php?id = index.php等等
RewriteEngine on
RewriteRule ^([^_]*)$ _index.php?id=$1 [L,QSA]
那就是创建页面_index.php
,并重写所有没有_
到这个页面的页面,这样它就不会进入无限循环,你可以选择~
而不是_
如果你认为你需要_在你的参数中
你有这样的规则:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} \s/+index\.php\?id=([^\s&]+) [NC]
RewriteRule ^ %1? [R=302,L]
# internal forward from pretty URL to actual one
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?id=$1 [L,QSA]
</IfModule>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.