我试图通过.htaccess重写$ _GET参数。我自己尝试过,但没有成功。检查我想要的内容:
mydomain.com/system.php?id=748742
到
mydomain.com/system/748742
我的/ var / www /目录:prntscr.com/ixpt1x
我尝试过使用此规则,但我的服务器一直说500内部服务器错误
RewriteRule ^system/(.*) /system.php?id=$1 [NC,L]
这是我当前的.htaccess文件
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteRule ^favicon.ico images/favicon.ico [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,NC,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)(/|)$ $1.php [L]
ErrorDocument 404 404.php
ErrorDocument 403 404.php
ErrorDocument 500 404.php
答案 0 :(得分:1)
这是对问题的评论中讨论的结果:
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteRule ^favicon.ico images/favicon.ico [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,NC,L]
RewriteRule ^/?system/(\d+)/?$ /system.php?id=$1 [NC,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)(/|)$ $1.php [L]
ErrorDocument 404 404.php
ErrorDocument 403 404.php
ErrorDocument 500 404.php
答案 1 :(得分:0)
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteRule ^favicon.ico images/favicon.ico [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,NC,L]
RewriteRule ^/?system/(\d+)/?$ /system.php?id=$1 [NC,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)(/|)$ $1.php [L]
ErrorDocument 404 404.php
ErrorDocument 403 404.php
ErrorDocument 500 404.php