1

我希望将“联系人”更改为index.php?controller=Front&action=$1&page=12404:

在此服务器上找不到请求的 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>

非常感谢任何帮助。

4

2 回答 2

0

确保上面的代码被放入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]
于 2013-10-06T07:58:24.043 回答
0

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>and</IfModule>行会导致 500 错误。

于 2013-10-06T00:21:03.857 回答