到目前为止,我有一个通用的查询“视图”,我将在大多数页面上使用.
我的重写是:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ $1.php?view=$2 [L]我的网址是:
classroom.php?view=creation
我想让它看起来像:
课堂/创作
我让它正常工作,但它把其他网址搞砸了
dashboard.php只是/dashboard
但当我第一次重写规则的时候.
这些事情很难理解。
我的问题是如何让/dashboard、/classroom /教室/创作工作?
编辑:我让它使用:
RewriteRule ^([a-zA-Z0-9_-]+)$ $1.php [L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ $1.php?view=$2 [L]发布于 2013-07-22 16:30:54
前两个规则用于外部重定向,它将.php转换为一个目录,就像格式一样,其余规则用于内部重定向,这将保留漂亮的URL,而不显示重定向。
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
# Redirect /classroom.php?view=creation to /classroom/creation
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+classroom\.php\?view=([^\s]+) [NC]
RewriteRule ^ /classroom/%1? [R=302,L]
# Redirect /classroom.php to /classroom and /dashboard.php to /dashboard
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(classroom|dashboard)\.php [NC]
RewriteRule ^ /%1 [R=302,L]
# Internally forward /classroom/creation to /classroom.php?view=creation
RewriteRule ^classroom/(.*)/?$ /classroom.php?view=$1 [L,QSA,NC]
# Internally forward /classroom to /classroom.php and /dashboard to /dashboard.php
RewriteRule ^(classroom|dashboard)/?$ /$1.php [L,QSA,NC]https://stackoverflow.com/questions/17790865
复制相似问题