【发布时间】:2019-01-11 06:56:09
【问题描述】:
我正在尝试为我的网站创建一个漂亮的 URL。
我有这种类型的 URL:game.php?game=some-game,我想将其显示为:game/some-game。我已经尝试在 htaccess 中编写和重写规则,但没有成功。
首先,我认为 htaccess 文件不起作用,但我输入的自定义错误页面工作正常。我尝试使用 QSA 标志但没有结果。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?game/(.*?)/?$ /game.php?game=$1 [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /game\.php\?game=([^\&\ ]+)
RewriteRule ^/?game\.php$ /game/%1? [L,R=301]
ErrorDocument 400 /Hacknet-INC/400.php
ErrorDocument 401 /Hacknet-INC/401.php
ErrorDocument 403 /Hacknet-INC/403.php
ErrorDocument 404 /Hacknet-INC/404.php
ErrorDocument 410 /Hacknet-INC/410.php
ErrorDocument 500 /Hacknet-INC/500.php
#Serve .htc files correctly, for IE fixes
AddType text/x-component .htc
php_value upload_max_filesize 300M
php_value post_max_size 10M
php_value max_execution_time 200
php_value max_input_time 200
【问题讨论】:
-
我猜
game.php>game=some-game应该是game.php?game=some-game? -
在哪里?
RewriteRule ^/?game\.php$ /game/%1? [L,R=301]在这一行? -
你问题的第二句。
标签: .htaccess url mod-rewrite