i have set up a local EzPUblish 5 installation, and it seems to work, with one exception: friendly URLs.
When I go to http://arabia.local/index.php/Frontpage, it works, but if I go to http://arabia.local/Frontpage, it tells me 404 not found.
I did some research already; I copied the .htaccess_root to .htaccess, I set the ForceVirtualHost=true in site.ini, I checked in my httpd.conf that AllowOverride All is set - I am running out of ideas here.
The files and settings you mentioned mostly concern eZ Publish's legacy part and will most likely have no effect on the frontend.
From what you're describing, the first thought that came to me was that the VHost configuration might be not complete. Please compare your configuration with the one eZ Systems officially provides: Virtual host setup and .htaccess example.
Are you perhaps missing the following line?
RewriteRule .* index\.php
Please also keep in mind that your webserver's root must point to the "web" directory, and if you are not using a VHost based configuration, the .htaccess file must reside in the "web" directory (but to be honest, I haven't seen a non-VHost based setup yet, so I'm not sure about the .htaccess method.
Nonetheless there should be no need to change anything in the "ezpublish_legacy" directory, especially not for an initial setup.
Related
I'm currently coding an Admin Panel, and for the sake of organization, I've made it so that all of the pages are located in a sub-directory instead of the root directory and I want to access these pages in the sub-directory from the root link. For example, the index.php is in the root directory and is accessible from:
http://localhost/index.php
But the rest of the pages are located in a sub-directory like so:
//What the current link is
http://localhost/pages/page.php
//What I want the link to be
http://localhost/page.php
Some of my pages are in sub-directories of the sub-directory like so:
//What the current link is
http://localhost/pages/page1/page.php
//What I want the link to be
http://localhost/page1/page.php
As you can see, I simply want to eliminate the primary sub-directory from the link, which is pages.
I've looked around on the internet and from what I can tell, this is achievable through .htacess but I couldn't find anything that worked.
You certainly won't find a perfect solution you can simply copy and paste to solve all your tasks. That expectation is a strange on. Instead you are expected to actually understand how the tools you want to use work and to be able to find your own solution. For that there really are enough good examples here on SO and in addition there is an __excellent_ documentation of apache's rewriting module available with just two mouse clicks.
Anyway, her is a suggestion, you still may have to tweak it to your situation:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?(.*)$ /pages/$1 [END]
In case you receive an internal server error (http status 500) using the rule above then chances are that you operate a very old version of the apache http server. You will see a definite hint to an unsupported [END] flag in your http servers error log file in that case. You can either try to upgrade or use the older [L] flag, it probably will work the same in this situation, though that depends a bit on your setup.
This rule will work likewise in the http servers host configuration or inside a dynamic configuration file (".htaccess" file). Obviously the rewriting module needs to be loaded inside the http server and enabled in the http host. In case you use a dynamic configuration file you need to take care that it's interpretation is enabled at all in the host configuration and that it is located in the host's DOCUMENT_ROOT folder.
And a general remark: you should always prefer to place such rules in the http servers host configuration instead of using dynamic configuration files (".htaccess"). Those dynamic configuration files add complexity, are often a cause of unexpected behavior, hard to debug and they really slow down the http server. They are only provided as a last option for situations where you do not have access to the real http servers host configuration (read: really cheap service providers) or for applications insisting on writing their own rules (which is an obvious security nightmare).
This may seem a dumb question, I need my symfony 3 app to behave different in production than it does in my local machine. I know there is an entry point for each env, app.php and app_dev.php
I don't want to change the application web/.htaccess file because it's followed by git, I was expecting an 'env' var or something similar in app/config.yml but there is also a config.yml and a config_dev.yml, so it has to be another place where I can define if I am working with prod or dev env.
Documentation says that I need to setup my apache server to use either web/app.php or web/app_dev.php, and this is my question. I'm using apache 2.4 and I tried using the following directive:
<VirtualHost *:8000>
<directory>
...
DirectoryIndex app_dev.php
</directory>
</VirtualHost>
I restarted apache, but when I type localhost:8000 in my browser, it keeps using the default app.php, I need my apache server to use app_dev.php, I don't want to use the built-in server because it gets buggy after a while.
Can anyone please help me with the apache configuration to use the dev env?
I think you have the following problems: regardless of which DirectoryIndex you define, the server also picks ups some settings from .htaccess. Could it be possible that you have another reference to app.php in there, like RewriteRule ^(.*)$ app.php [QSA,L]?
Then you could do the following: move that exact setting from .htaccess to your server configuration, both locally and on the production server. Then you can keep all other settings independent from your enviroment.
If this does not help yet, please share the content of .htaccess.
Another way of solving could be to use a recent Symfony version and put everything that might change between environments in the .env file. Don't put it under version control, as this file might contain sensitive information. Then have a look at the current basics: you no longer have a app.php and app_dev.php, as the changes were only little. A common index.php is used, and it reads all current settings from .env
Working with zf2, we have configured the project successfully in local env, we deployed the same code to server, but there..only the IndexController action is working.
like www.project.com/public/ works,
but when I access other modules like
www.project.com/public/country doesn't work.
This means the mod_rewrite rules to rewrite all requests to your index.php file are not being used. Generally this means either:
The .htaccess file was not uploaded (check the public folder on the server to see if it's there)
The .htaccess file is being ignored (check AllowOverride for the vhost on the live server)
Also, really public/ should not appear in your URLs. Unless you are using shared hosting (where this can be tricky), you want to point your vhost's document root at the public folder.
In a proper Zend setup an error should come from Zend. When you get an error like this, returned from Apache, your apache configuration is not working. Your Zend application isn't even considered, i.e. the index.php in your public folder.
It's a save guess that your [public/].htaccess isn't used. Check your apache web configuration. Most likely you're missing the AllowOverride All statement which is usually inside the <Directory> statement.
And as mentioned by Tim you really should not have public/ in your path to begin with.
I have a weird problem. I develop my sites on localhost and after that i distribute it server side. Most of the time this is working as expected but now notice something weird and cannot figure out what the problem is.
On the server all RewriteRule redirects but without expected queries. Something like this is working fine on localhost but not on the server:
RewriteEngine On
....
....
RewriteRule .....
EDIT: Changed entries for security reasons, sorry!
....
....
Does anybody knows what is going on? Do i miss something? Why are the queries not passed thru? Is it a server configuration? Cannot find anything about it on the internet.
Thank you for your comments.
EDIT: SOLUTION below, second comment. Has something to do with what apache handles first.
#Erwinus, the "Perdir" functionality that you discuss is standard in Apache but not well understood. Apache will probe for, then open and read all existing .htaccess files on the path to a script filename. (Ignoring the RewriteOptions inherit chase which is rarely chosen) it uses the deepest .htaccess file that it finds that has RewriteEngine On.
I would therefore differ from Mario's view in that IMHO its almost impossible to get a parent directories rewrite rules to preempt a child directory set -- the default action of Apache is to ignore the parent. I explain in a more detail in this blog article.
These things are nearly impossible to debug. But mod_rewrite offers one feature that you should set up to investigate this:
RewriteLog /tmp/rewritelog.txt
RewriteLogLevel 2
The RewriteLog directive however cannot be used from .htaccess. You need to declare it in the vhost or main server configuration. If level 2 is still insufficient, then try 3.
Otherwise I'd just would advise you to try a RewriteBase, since you seem to match varying directory levels with your rules. Possibly repeat your rules in the subdirectories (streambutler/) again. Apaches mod_rewrite is peculiar and ignores them in the parent dir sometimes.
I have: brand new clean copy of Kohana 2.3.4 (tried 2.4 RC1 also), a controller named 'index' on a Debian with Apache 2.2.9.
When i type address like http://localhost/kohana/index/index i expect controller 'index', action 'index' to be executed. It works on Windows localhost, works on shared hosting. But does not on my Debian server.
I've debugged and found, that $_SERVER['PATH_INFO'] isn't correct. It omits the first 'index' in the URI, so i can get to 'index/index' by going to 'index/index/index'. So that is what i want to fix.
Does anybody know how this could be solved?
I'm guessing it actually occurs in your .htaccess file or Apache config, not Kohana specifically. First of all, make sure that the example.htaccess file that comes with Kohana is renamed to .htaccess, and you may have to restart Apache.
If you are using .htaccess to hide the index.php part of the path, check to see what the RewriteBase setting is:
RewriteBase /kohana/
If you installed it in the root of your web server (as in production, or using a separate port for localhost), then it should be changed to:
RewriteBase /
This is my own personal most common error in setting up new sites and development environments, by the way. This is also true for CodeIgniter and other related PHP frameworks.
Does your Apache install on the Debian server actually have mod_rewrite? It would be good to confirm that. Here's one way to do that.
Further diagnosis to see if it is Kohana or Apache's fault includes adding back in the index.php portion of the path. In your case, try http://localhost/kohana/index.php/index. Finally, I have to agree with sarfraz above that naming your controller "index" is just begging for trouble. My own convention is to call it "home" and to edit the default route accordingly.
It turned out to be mod_negotitaion. It damn mod rewrites my /index/index to /index.php/index, cause it thought i've missed .php
So anyone who encounter this issue, just disable mod_negotiation and have a good time