使用.htaccess隐藏特定URL的文件夹名称

时间:2016-06-29 12:37:17

标签: .htaccess

我有一个根文件夹和一个子目录。我的项目在子目录中。我想在我的所有网址中显示该子目录,除了一页是show_film.php

我希望它是

select id into @data from table_name where name='john'

而不是

www.xyz.com/show_film/

我曾尝试过

www.xyz.com/subdirectory/show_film/

如果我使用上面的代码,我总是会收到404错误。我将上面的代码放在root htaccess

My Root Htacess 选项+ FollowSymLinks RewriteEngine On RewriteBase /

RewriteRule  ^show_film/$ subdirectory/show_film.php
RewriteRule  ^show_film$ subdirectory/show_film.php

1 个答案:

答案 0 :(得分:1)

尝试:

RewriteEngine on

RewriteCond %{THE_REQUEST} /subdir/(show_film)\.php\sHTTP [NC]
RewriteRule ^ /%1 [R,L]
RewriteRule ^show_film/?$ /subdir/show_film.php [NC,L]