0

My question is the same as: Zend Framework 2 without Vhost configuration but the solution didn't solve my problem.

I'm getting a customised 404 page.

my project is in a sub-directory, and I believe the .htaccess in the parent directory is stopping it from working.

note: I can't delete that one because there is another project running there

htdocs/.htaccess:

Options -Indexes
Options +SymLinksIfOwnerMatch
RewriteEngine on

RewriteBase /

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

RewriteRule ^transcripts/$ https://spreadsheets.google.com/a/ci4tcm.com/ccc?    key=0AodnCB9Mr1K1dFFmbGhOc3V4RjBvNzZxSE9EZ1dtSnc&hl=en#gid=0 [R,NC]

# ErrorDocument 404 /pages/404.html
# ErrorDocument 500 /pages/404.html
# ErrorDocument 403 /pages/404.html

# RewriteRule ^css(/)?$ / [R]



# RewriteRule ^download/([A-Za-z0-9.]*)/([A-Za-z0-9.]*)$ /download/$1/$2/ [R]
# RewriteRule ^download/([A-Za-z0-9.]*)/([A-Za-z0-9.]*)/$ /download.php?test=$2&fol=$1

RewriteRule ^download/([A-Za-z0-9.]*)$ /download/$1/ [R]
RewriteRule ^download/([A-Za-z0-9\+.-\s]*)/([A-Za-z0-9\+.-\s]*)$ /download.php?folder=$1&file=$2 [L]

RewriteRule ^download/([A-Za-z0-9.]*)$ /posters/$1/ [R]
RewriteRule ^download/([A-Za-z0-9\+.-\s]*)$ /images/wellbeing_posters/pdfs/$1 [L]

AddHandler server-parsed html

RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^(.*)$ "http\:\/\/www\.another-domain\.com\/$1" [R=301,L]

# A bunch of redirect 303's here

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

htdocs/booking/ < Zend application here > (solution to other question).

RewriteEngine On

RewriteRule ^\.htaccess$ - [F]
RewriteCond %{REQUEST_URI} = ""
RewriteRule ^.*$ /public/index.php [NC,L]

RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]

RewriteRule ^public/.*$ /public/index.php [NC,L]

so my question is, how do I bypass the parent directory .htaccess rule when the user wants to enter the physical sub directory with the Zend Application?

Community
  • 1
  • 1
fenerlitk
  • 5,414
  • 9
  • 29
  • 39
  • The link to the other question is incorrect. It's pointing to the Ask page. – Ruben Apr 29 '14 at 19:39
  • What is it that's not working? The parent folder .htaccess rules just enforce `www` in the URL, they won't be causing any issues with the rules in your ZF project. – Tim Fountain Apr 29 '14 at 20:31
  • @TimFountain I am not allowed to configure virtual directories. And the answer in the link didn't work for me, so I thought it could be the other htaccess that's causing it. I'm getting a customised 404 not found page when trying to access my ZF App. – fenerlitk Apr 29 '14 at 20:48
  • A ZF 404 page? If so, it's more likely to be a routing issue. – Tim Fountain Apr 29 '14 at 20:54
  • @TimFountain not a ZF 404, it's another custom 404 page. See: http://www.ci4tcm.com/c-booking/ which is the root of the ZF app. Just noticed that htdocs/ contains a Wordpress app – fenerlitk Apr 29 '14 at 21:02

1 Answers1

0

Your edited question added a whole load of stuff to the .htaccess in the parent folder which changes things somewhat. Assuming you're able to edit that htaccess, the easiest thing to do would be to move the ZF rules into it. Just change any lines that include public and add c-booking before it. So as an example, the last line would look like:

RewriteRule ^c-booking/public/.*$ /c-booking/public/index.php [NC,L]

Also be aware that this is a less secure way to host an app. If you have any non-PHP config files, cache files etc. (things that would normally be outside the web root), make sure they aren't viewable through a browser.

Tim Fountain
  • 33,093
  • 5
  • 41
  • 69
  • Thanks for your answer.change the lines after I move them to the other htaccess or do I not need to move them if I change the line? How do I hide those files from the browser? I'd rather not touch that htdocs if I don't have to. – fenerlitk Apr 29 '14 at 21:27
  • If you're moving the lines you need to edit them so the paths are correct. – Tim Fountain Apr 29 '14 at 21:40
  • is there a solution that I don't need to move the lines? – fenerlitk Apr 29 '14 at 21:42