我希望将"联系人"更改为index.php?controller=Front&action=$1&page=12
,并得到404:
在此服务器上找不到请求的 URL/symfony/LocAtMe/web/contact"
这是我的 htaccess 中的代码:
AddType application/x-httpd-php .tpl .inc
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ index.php?controller=default&action=index [QSA]
RewriteRule ^contact$ index.php?controller=Front&action=$1&page=12 [QSA, L]
RewriteRule ^([a-zA-Z0-9]+)$ index.php?page=$1 [QSA]
</IfModule>
任何帮助非常感谢。
重写标志中的QSA,
后不能有空格:
RewriteRule ^contact$ index.php?controller=Front&action=$1&page=12 [QSA,L]
# can't have a space here ----------------------------------------------^
虽然这不应该导致 404。您还应该仔细检查是否已加载mod_rewrite。如果未加载,则删除<IfModule mod_rewrite.c>
和</IfModule>
行应导致 500 错误。
确保上面的代码放在DOCUMENT_ROOT/symfony/LocAtMe/web/.htaccess
中,然后使用以下代码:
RewriteEngine on
RewriteBase /symfony/LocAtMe/web/
RewriteRule ^$ index.php?controller=default&action=index [QSA,L]
RewriteRule ^(contact)/?$ index.php?controller=Front&action=$1&page=12 [QSA,L]
RewriteRule ^([a-zA-Z0-9]+)/?$ index.php?page=$1 [QSA,L]