htaccess URL重写 - 在服务器上找不到请求的URL

时间:2014-09-23 09:39:11

标签: regex apache .htaccess mod-rewrite

在加载Uniimart1609/S/page.phpUniimart1609/page.php时需要隐藏一个文件夹 在linux中

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule Home_Page.php$ S/Home_Page.php 
</IfModule>

被重定向http://Uniimart1609/Home_Page.php这工作正常,但是当我重写htaccess时

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) /S/$1.php [L,NC,QSA]
</IfModule>

获取在此服务器上找不到请求的URL /S/Home_Page.php。请求帮助

1 个答案:

答案 0 :(得分:0)

你的规则如下:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /Uniimart1609/

RewriteCond %{THE_REQUEST} /S/(\S*) [NC]
RewriteRule ^ %1? [R=302,L,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/S/$1\.php -f [NC]
RewriteRule ^([^./]+)/?$ S/$1.php [L]
</IfModule>