我的网站和数据库存在问题。我创建了一个pages
表,我想在其中使用page title
作为路径。
http://website.com/page-title/
我使用.htaccess文件:
# BEGIN
<IfModule mod_rewrite.c >
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule >
# END
但是它没有用?我是否需要创建目录文件夹?
答案 0 :(得分:0)
将所有请求推送到索引页面,然后该页面将仅发送到浏览器。您的服务器$_SERVER['REQUEST_URI']
应该更改,但应始终通过index.php
页面运行:
<强> /。htaccess的强>
RewriteEngine On
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [NC,QSA,L]
<强>的index.php 强>
<?php
// You should see the REQUEST_URI change here.
print_r($_SERVER);