1
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
# load index.php by default
DirectoryIndex index.php
RewriteBase/
# for all other requests load room.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((?!(index|room)\.php).+)$ room.php?u=$1 [L,NC]
我的htaccess目前会如果URL包含任何东西,但如果没有它会简单直接到index.php
htaccess的 - 如何不是基于URL模式重定向
的根目录下,如http://www.example.com/anythingelse
人重定向到room.php
但我需要能够不包含此特定模式的重定向,以便我可以在特定文件夹中创建内容。例如
http://www.example.com/1
http://www.example.com/2
http://www.example.com/3
http://www.example.com/4
这是可能的吗?
似乎并不奏效 – 2014-10-06 17:14:27
是'HTTP:// www.example.com/1'仍然要'HTTP:// WWW .example.com的/ room.php?U = 1'? – anubhava 2014-10-06 17:16:41
不,这将是一个实际的目录 – 2014-10-06 17:17:19