目前我工作在我的网站转移到搜索引擎友好的URL(在本地主机)友好,PHP SEO用干净的URL
这里的原始URL与查询字符串:
http://{ip}/sitename/item.php?category=44
我想转换为:
http://{ip}/sitename/item/category/44
的.htaccess文件(与item.php相同的目录):
DirectoryIndex index.php
Options -Indexes
<files page>
ForceType application/x-httpd-php
</files>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^.*$ item.php%{REQUEST_URI} [L]
RewriteRule ^/item/([0-9]+) /item.php?category=$1
</IfModule>
<Files *htaccess>
Deny from all
</Files>
在
item.php
,我用$_GET['category']
$category = preg_replace('/[^0-9]/', '', $mysqli->real_escape_string($_GET['category']));
$list = $listing->get_items($category, $mysqli);
if($list == 0){
echo '<p><h2>Page not found</h2></p>';
die();
}
问题1: 当我装http://{ip}/sitename/item/category/44
,页面无法得到变量传递到get_item()
,页面显示Page not found
? 44是假设返回一个值。
问题2: 我的页面没有加载的引用文件,所有*.css
*.js
等被忽略?
你的重写基地定义在哪里?我相信你错过了正确的位置。 –