Should I set rewrite rules on an ASP.Net MVC site with heliontech IISRewriter Globally or by folder with wordpress? - mod-rewrite

I'm using IIS6 (unfortunatly) and have built an ASP.Net MVC app; IIS is set up for wildcards to make the routing work but I have two virtual directories that contain wordpress installations which works fine.
I have two .htaccess files (one in each wp install) that handles their rewriting fine, but I want to setup a rewrite from /about to /blog/about. How would I do that and is it better to create all the rewrites in one .htaccess at the root of the site?

Use separate files, it helps isolate problems if they occur.

Related

How to remove directory name from url with global.asax code

I am using MVC routing in asp.net Web forms and I want to remove the folder/directory name appended in the URL. Locally this works fine but I have the following address now appearing on Godaddy shared hosting.
www.mywebsite.com/my-folder/contact
but I want like this
www.mywebsite.com/contact
I have tried web.config techniques but no success that's why I am asking is there any way to redirect this using Global.asax.

How to develop mobile application using CodeIgniter?

I wanted to develop the mobile application using CodeIgniter. Is it possible.
Web application is already built on CodeIgniter
You'll have to create a new controller and add appropriate routes. When I had to do this, I just used a controller that inherited from my primary site controller and added these routes to my routes config (Mine was located in /system/application/config/routes.php. Yours also may look different and this code snippet assumes you have a page function):
$route['mobile/(:any)'] = "site/mobile/page/$1";
$route['mobile'] = "site/mobile/page/home";
Then you'll want to add a rule to your htaccess file to ensure anything going to m.example.com/whatever gets directed to the right path (e.g. /mobile/whatever).
RewriteCond %{HTTP_HOST} (^mobile\.|^m\.)(.*) [NC]
RewriteRule (.*) /index.php/mobile/$1 [L]
From there it should route into your mobile controller. Form me this was in /site/controllers/mobile.php. My primary site controller was /site/controllers/site.php
You'll want to recreate whatever logic you use in your site controller in you mobile one excluding desktop assets and including mobile ones and rendering your pages appropriately. Unfortunately that's about all I understand of the process. It was mostly my coworker's work that got the mobile controller working and I only used it once or twice, but this should work.
Yes, it is posibble. It all depends on your strategy. If you decide to go with Responsive Design, codeigniter makes no difference. If you decide on Adaptive you shoul read the about codeigniter's user-agent library -
https://ellislab.com/codeigniter/user-guide/libraries/user_agent.html
To read about RWD and AWD visit http://www.techrepublic.com/blog/web-designer/what-is-the-difference-between-responsive-vs-adaptive-web-design/

How do I configure Laravel to properly work on localhost?

So I have this website, that some else build on Laravel. Since I need to make some changes I want to copy this website locally and make it work locally, so that later on I can apply the changes. I really don't want to work on the live site.
So I copied the whole website in my local folder but in order for me to see each page I have to follow this link:
http://localhost/XXXproject/html/index.php/auth/signin
I would like to know, where can I fix this. I want to remove the index.php from the url and be able to see the images without getting 500 errors everywhere. Something more like this:
http://localhost/XXXproject/html/auth/signin
And this is my htaccess.
RewriteCond %{REQUEST_URI} !^/html
RewriteRule ^(/?)(.*) /html/$2
During development I would recommend using Laravel's little HTTP server which will host the site without any external web server software such as Apache, where configuration might be an issue.
You can do this by going into the root directory of the project and typing:
php artisan serv
However if you do want to use a webserver for local development purposes with Laravel 4, you'll need to configure the rewrite rules appropriately. Although it does seem the rewriting is working to some extent, you may need to configure your webserver to consider index.php as a root document. Can't really help you more than that without more information on your webserver software and its current configuration.
Finally I solved it, I went through the installation and configuration steps from the website, and realize that I was working with a htaccess that was under wamp\www folder, I even tried making one for wamp\www\xxxproject.
But when following the steps I realized there is a htaccess inside the public folder from the project, I changed that one with the one from the website and now it works!

Creating an admin section controllers and views in Code Igniter 2.0

I have created my site with controllers such as about, products etc... which gives me example.com/about/ etc..
How would I create a admin section with the same controller name, like example.com/admin/about or example.com/admin/products ?
How do I organize my controllers?
2 more options to compliment WebweaverD answer.
Use Modular Separation
Create a second application folder and index file, that will be responsible for admin, connect them to the same system folder.
The second option is really easy to manage once you have set it up. There are variations but I find the structure below to be the most convenient.
mykewlwebsite.com
apps/
frontend/
app/ frontend codeigniter application folder
public/
index.php
assets/ frontend js, css, images
backend
app/ backend codeigniter application folder
public/
index.php
assets/ backend js, css, images
config/
database.php
constants.php
system/ codeigniter system folder
The database.php file contains the code from CodeIgniter's config/database.php and is shared for all applications of your project - simply remove all code and add require_once('../../../../config/database.php'); to the config/database.php
index.php files inside public folders have two important variables $system_path and $application_folder, change them to
$system_path = '../../../system/codeigniter';
$application_folder = '../app';
constants.php file can have some constants like the ENVIRONMENT constant from the index.php files and some other. Just require_once() it from the index.php files.
Though there are pros and cons.
PROS
For those of you, who are developing on localhost and deploying to servers via FTP or other systems can simply upload one folder - apps and overwrite the target folder without fear of overwriting database.php settings (I'm sure most of you have them different from the local ones).
Adding one more application is easy - just duplicate one of existing. You can add as many applications as you want - api, ajax, user cabinet, etc.
CONS
This structure is meant to be used if you have a domain as mykewlwebsite.com and have the ability to add sub-domains to it, so you just configure the home folders for each of them:
mykewlwebsite.com: path/to/mykewlwebsite.com/apps/frontend/public/
admin.mykewlwebsite.com: path/to/mykewlwebsite.com/apps/backend/public/
api.mykewlwebsite.com: path/to/mykewlwebsite.com/apps/api/public/
You have a few options here:
1) CREATE A SUBFOLDER - Put them in a folder called admin within the controllers directory (in application/contollers/admin/products.php)
A word of warning here is that you can only go one folder deep or codeigniter gets upset. Also, it will use first level controller/methods first so be careful of naming conflicts - e.g if you have an admin controller with a products method in it, that will get called before it looks in the admin directory for a products controller. (when going to example.com/admin/products)
2) USE THE ROUTES FILE - If it is just the urls you are worried about you could just call the controllers whatever you want and use the application/config/routes to redirect those paths to the controllers you want like this:
controller name: admin_products.php
routes file:
$route['admin/products'] = "admin_products";
3) USE A MASTER CONTROLLER FOR ALL - Final option would be to have a single admin controller and use named methods inside it, so for example you have admin.php controller with a products method within it this would then be called by admin/products uri (this will probably get messy though in a big application/site - not recommended)
Hope I have explained this OK for you, if you need any clarification please ask and I will try to elaborate.

CodeIgniter How to create Multiple Site with One CMS

I want to create a blog site with only one CMS. This CMS will be in different domain.
For example: mycms.com
Then my blog sites are also in different domains.
For example: website1.com, website2.com, website3.com
They will all use mycms.com as their admin
*Images will be uploaded in mycms.com/images/ so all the 3 websites will get the images from this directory
If images are loaded on website1.com from the main database, they should be displayed as if they're from website1.com. So for example website1.com/images/cat.jpg instead of mycms.com/images/cat.jpg
How will I build this using codeigniter?
You can use the same CodeIgniter /System and /Application folders for all the websites if you like; just make sure all the index.php files are setup to use those same folders for $system_path and $application_folder respectively. Note that these sites also need to reside on the same server.
You can serve up different content by checking $_SERVER['HTTP_HOST'] for the domain the request came from.
As for htaccess you should be able to use %{HTTP_HOST}/$1 or %{HTTP_HOST}$1 (depending on server config) to make the rewrite rule dynamic.
I am actually building a similar project right now using CodeIgniter but there are also several other projects available like halogy, codefight, pyro (with an extension), and many others.
CodeIgniter has a System and an Application folder. You could have one global system folder and then one application folder for each of your subdomains, or you could have one application folder and just make your subdomian folders parallel with your www folder.

Resources