1

I had a root folder and a subdirectory in it. My project is in subdirectory. I want to show that subdirectory in all my urls except for one page which is show_film.php

I want it to be

www.xyz.com/show_film/

instead of

www.xyz.com/subdirectory/show_film/

I had tried

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

I always get 404 error if I use the above code. I am placing the above code in root htaccess

My Root Htacess Options +FollowSymLinks RewriteEngine On RewriteBase /

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]

1 Answer 1

1

Try :

RewriteEngine on

RewriteCond %{THE_REQUEST} /subdir/(show_film)\.php\sHTTP [NC]
RewriteRule ^ /%1 [R,L]
RewriteRule ^show_film/?$ /subdir/show_film.php [NC,L]
Sign up to request clarification or add additional context in comments.

11 Comments

where to add these lines?? In root htacess or in the subdirectory htaccess @starkeen
Place it in root.htaccess.
What url are you going to?
This rule redirects /subdir/show_file.php to root /show_file.php and then internally maps the file back to subdir. its working fine on my server.
Should I have to place the code at the top of my root htaccess @starkeeen
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.