Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用.htaccess从特定URL隐藏文件夹名称_.htaccess - Fatal编程技术网

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

使用.htaccess从特定URL隐藏文件夹名称,.htaccess,.htaccess,我有一个根文件夹和一个子目录。我的项目在子目录中。我想在我的所有URL中显示该子目录,除了一个页面show_film.php 我希望是这样 www.xyz.com/show_film/ 而不是 www.xyz.com/subdirectory/show_film/ 我试过了 RewriteRule ^show_film/$ subdirectory/show_film.php RewriteRule ^show_film$ subdirectory/show_film.php 如果我使

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

我希望是这样

www.xyz.com/show_film/
而不是

www.xyz.com/subdirectory/show_film/
我试过了

RewriteRule  ^show_film/$ subdirectory/show_film.php
RewriteRule  ^show_film$ subdirectory/show_film.php
如果我使用上面的代码,我总是得到404错误。我正在根目录下放置上述代码

我的根接触 选项+FollowSymLinks 重新启动发动机 重写基/

RewriteCond %{HTTP_HOST} ^abc\.in$ [NC]
RewriteRule ^(.*)$ http://www.abc.in/$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php

RewriteRule (.*)\.xml(.*) $1.php$2 [L]

RewriteCond %{REQUEST_URI} (\.ico|sitemap\.xml|\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteRule ^(.*)$ $1 [L]

RewriteCond %{REQUEST_URI} !(category)
RewriteRule .? - [S=6]
RewriteCond %{REQUEST_URI} !(/page/)
RewriteRule .? - [S=2]
RewriteRule ^category/(.*)/page/(.*)/$ index.php?action=category&slug=$1&page=$2 [L,QSA]
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteRule ^category/(.*)/page/(.*)$ http://%1/category/$1/page/$2/ [L,R=301]

RewriteRule ^(.*)/(.*)/$ index.php?action=category&slug=$2 [L,QSA]
RewriteRule ^(.*)/$ index.php?action=category [L,QSA]
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteRule ^(.*)/(.*)$ http://%1/$1/$2/ [L,R=301]

RewriteCond %{REQUEST_URI} !(tag)
RewriteRule .? - [S=6]
RewriteCond %{REQUEST_URI} !(/page/)
RewriteRule .? - [S=2]
RewriteRule ^tag/(.*)/page/(.*)/$ index.php?action=tag&slug=$1&page=$2 [L,QSA]
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteRule ^tag/(.*)/page/(.*)$ http://%1/tag/$1/page/$2/ [L,R=301]

RewriteRule ^(.*)/(.*)/$ index.php?action=tag&slug=$2 [L,QSA]
RewriteRule ^(.*)/$ index.php?action=tag [L,QSA]
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteRule ^(.*)/(.*)$ http://%1/$1/$2/ [L,R=301]

RewriteCond %{REQUEST_URI} !(blog)
RewriteRule .? - [S=7]
RewriteCond %{REQUEST_URI} !(/page/)
RewriteRule .? - [S=2]
RewriteRule ^(.*)/page/(.*)/$ index.php?action=blog&page=$2 [L,QSA]
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteRule ^(.*)/page/(.*)$ http://%1/$1/page/$2/ [L,R=301]

RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteRule ^(.*)/(.*)/$ http://%1/$2/ [L,R=301]
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteRule ^blog$ http://%1/blog/ [L,R=301]
RewriteRule ^(.*)/$ index.php?action=blog [L,QSA]
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteRule ^(.*)/(.*)$ http://%1/$2/ [L,R=301]
RewriteRule ^(.*)/(.*)/$ index.php?action=blog&slug=$2 [L,QSA]

RewriteCond %{REQUEST_URI} (ajax|sitemap)
RewriteRule .? - [S=2]
RewriteRule ^(.*)/$ index.php?action=blog&slug=$1 [L,QSA]
RewriteRule ^(.*)$ index.php?action=$1 [L,QSA]

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
RewriteCond %{HTTP_HOST} ^abc\.in$ [OR]
RewriteCond %{HTTP_HOST} ^www\.abc\.in$
RewriteRule ^post\/goa\-government\-websites\-hacked\-allegedly\-palestine\-hackers\/$ "http\:\/\/www\.cyberintelligence\.in\/goa\-government\-websites\-hacked\-allegedly\-palestine\-hackers\/" [R=301,L]
尝试:


在哪里添加这些行??在root htacess或子目录htaccess@starkeen中,将其放在root.htaccess.What url中?此规则将/subdir/show_file.php重定向到root/show_file.php,然后在内部将文件映射回subdir。它在我的服务器上工作正常。我应该把代码放在根htaccess@starkeeen的顶部吗
RewriteEngine on

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