Recently I created an application (sales portal) in PHP for a small company. The company had a website developed in word press. Since I hadn't worked with word press the way I embedded my application in the website is I simply created a sub directory on the host and uploaded my application there. E.g:
domainname.com - their website
domainname.com/portal - is where my application is placed (the 'index.php' file).
Since a month I am learning Zend Framework 1.8 and I want to rewrite the portal in Zend framework since I wrote the portal from scratch and its core is not as secure as it would be if it implements the Zend framework.
My question is can I include the Zend framework application into the wordpress website the way I did it with 'from-scratch' application, by creating a sub directory on the host and upload the application there? And if yes how should I configure the Zend application so that it recognizes 'domainname.com/portal' as the domain name (as home directory).
The problem that I face right now is that when I type http://www.domainname.com/portal/sales it returns 404 because there is not such directory on the server. Of course what I mean with the above mentioned link (domainname.com/portal/sales) is:
site: domainname.com/portal
controller: sales
action: index
I tried 'domainname.com/portal/index.php/sales' but when someone opens the portal with this link 'domainname.com/portal/' the next linked that is clicked (e.g. domainname.com/portal/sales) shows 404.
(note: the website http://www.domainname.com should be accessible also)
Thanks in advance.
I believe that wordpress ues a .htaccess to redirect all URLs to its index.php.
This is the .htaccess I pulled out of a test installation:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
In your case, you would need to modify the .htaccess file so that it does not care about what's in http://domainname.com/portal.
In your case, your .htaccess file could look at this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} "/portal/"
RewriteRule (.*) $1 [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
Basically, what this does is that it ignores the subfolder 'portal' and doesn't process it with any of the normal rules.
However, there might be a down side: If future versions of wordpress updates the .htaccess file, then you will need to make those changes to the file again.
[C]an I embed the Zend framework application into the wordpress website the way I did it with 'from-scratch' application, by creating a sub directory on the host and uploading the application there?
Yes you can.
[H]ow should I configure the Zend application so that it recognizes domainname.com/portal as the domain name (home directory)[?]
Sure, please see Base Url and SubdirectoriesÂDocs how you need to configure your request/routing for your Zend Framework based application.
Related
ReactJS application sits inside page path - www.example.com/some-path
Reactjs App is part of page and not cover full page - so we cant add extra subdirectory and add reactjs there.
How to change htaccess to make situation where all paths after some-path - (some-path/foo or some-path/foo1) listening my reactjs app inside some-path
At the moment it works only if I visit some-path, but if I try to open some-path/foo then it takes server path that is empty and send empty page 404.
I have deployed multiple working single-page applications (reactJS) into main route of server and used htacces like that:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>
There is no any some-path folder's inside server because it is wordpress application where we hold our react app.
Can anyone help?
Found a working solution
I made its own directory for (some-path)
Inside that path added:
index.php - with wordpress (header, footer) - middle of that added my reactjs application
.htaccess to listen that reactjs app - now all routes runs well
I got a hosting with WordPress engine installed and inside the root of WP engine folders I've created another web application which is having problems with URLs containing .profile word. When this text is added to URL I'm always receiving 404 error.
Here's an example:
WordPress blog URL: https://mainsite.com
Sub web application folder name: webapp
Sub web application access URL: https://mainsite.com/webapp/
So, when I try to access URL like this: https://mainsite.com/webapp/login.php?code=user.profile I'm receiving error 404. At the same time URL like this: https://mainsite.com/webapp/login.php?code=user.profilb is working fine (2nd URL got last letter replaced by another symbol).
I think this is an issue with WordPress default mod_rewrite settings, here they are:
# 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
I got no clue at all why this could happen with .htaccess file like this. Could you suggest please?
It turned out that the issue was with mod_security of a2hosting. They were blocking all sensitive linux files and folders, like: .profile, .htaccess, .bashrc...
Hope, this will help someone.
I have this web api project which is developed by other company. The file structure is:
/project
---/app
---/ApiEndpoint.php
---/public
---/index.php
The DocumentRoot is pointing to /project/public. The index.php is working (http://myapi.com/), however when I try to browse into the api endpoint http://myapi.com/api/endpoint I got 404 error.
How do I configure the .htaccess to rewrite this condition?
/project/public/.htaccess config
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*)$ /index.php?path=$1 [NC,L,QSA]
</IfModule>
The current configuration is there to make sure every request go to index.php (that is probably dispatching requests in some way) except for the files that actually are in the public directory (probably needed for static files like images, and such).
If you wrote a php yourself to be directly called by http://myapi.com/api/endpoint, you should put it in /project/app/public/api/endpoint/index.php.
BUT I suspect you should study that application more and understand the current dispatching method, before doing that.
I am creating an application with Yii Framework and want to redirect http://mydomain.com/yiiframework to http://mydomain.com/yiiframework/default so i created .htaccess file and i put this content on it but it don't redirect anything :
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /default/index.php [L]
my questions are :
1 - what is wrong in my htaccess file ?
2 - is that a good way to create admin section and put other stuff in default folder ?
Edited :
I accidently find it out ,i changed .htaccess to this :
RewriteEngine on
RewriteRule ^$ http://mydomain.com/yiiframework/default/index.php
and it server my purpose , but the mystery is :
^$
shows the start of line and the end of the line , what this Regular Expressions means?
to create admin-panel best practice is to create separate application for backend and frontend, which share common things with fontend, backend as in this boilerplate,https://github.com/clevertech/YiiBoilerplate
or
you sholud create single application and devide it into modules, each module have code for both frontend and backend as you see this in many yii based open source applications like Zurmo, Yupe CMS, X2Engine,
i would prefer second approach which is modular and maintainable code, slightly hard but best
I have a normal php script which I want to use in a CakePHP application (created by a previous developer). I have made a folder in my CakePHP webroot folder:
Httpdocs -> app -> webroot -> folderx
Is it possible to run a standalone script in this folder?
Also, my script takes in an id, for example www.domain.com/folderx/index.php?id=123 and draws the information (ex name of the product) from the DB. However, I wish to rewrite the URL to:
www.domain.com/folderx/name-of-the-product. Is this possible at all?
The webroot already has an .htaccess file which handles the CakePHP rewrites. Would I be able to use a new .htaccess file with the rewrite instructions in www.domain.com/folderx/ for my standalone script.
You need to modify the existing rewrite rules to not rewrite requests that include /folderx/ to CakePHP. If you need help with that and the mod_rewrite manual isn't enough, share your rewrite rules.
By default, your htaccess, in webroot, must contain:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
In this case, all the folders and files in the webroot should open normally