【发布时间】:2014-01-02 12:39:54
【问题描述】:
我正在将查询重写为对 SEO 友好的 URL..
基本上,我正在重写http://example.com/forums/category?v=Name
致http://example.com/forums/category/Name
我的问题是 $_GET['v'] 返回 Name.php 而不是 Name.. 这是我的 .htaccess:
<Files .htaccess>
order allow,deny
deny from all
</Files>
ErrorDocument 400 /404.htm
ErrorDocument 401 /404.htm
ErrorDocument 403 /404.htm
ErrorDocument 404 /404.htm
ErrorDocument 500 /404.htm
RewriteEngine on
RewriteRule ^(.*)/$ /$1 [R,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(([^/]+/)*[^.]+)$ $1.php [L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*[^.#?\ ]+\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*[^.]+)\.php http://example.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /forums/view\.php\?v=([^&]+)&a=(.+)\ HTTP
RewriteRule ^ /forums/view/%1/%2 [R=301,L]
RewriteRule ^forums/view/([^/]+)/([^/]+)/?$ /forums/view.php?v=$1&a=$2 [L]
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /forums/category\.php\?v=([^&]+)\ HTTP
RewriteRule ^ /forums/category/%1 [R=301,L]
RewriteRule ^forums/category/([^/]+)/?$ /forums/category.php?v=$1 [L]
【问题讨论】:
-
$_GET['v']在哪个文件中? -
http://example.com/forums/category/Computing返回Computing.php
标签: php apache .htaccess url-rewriting url-redirection