Moved Yii Website From Linux Server To Windows Server

Hi,

I don’t know anything about the yii framework, although im familiar with MVC concepts as i’ve used ASP.NET MVC a lot.

Anyway I have copied over a yii website from a linux server to a windows server (the windows server has php).

The home page of the web site / application shows fine but all the other pages show 404 errors, I guess it might be a routing problem but don’t know where to start.

Any advice?

If the application used to work under Linux it may be a routing problem. Post the urlManager rules in protected/config/main.php. They may be set up for "pretty" URLs, or perhaps to hide index.php; refer to this topic in the Guide. It also depends on the webserver: is it IIS or Apache?

Need more information…

Thanks for the reply.

I don’t know for sure whether its IIS or Apache, its a shared hosting server which we have access to though a web based control panel - Parallels Panel.

I guess its IIS because you can put asp scripts on there as well as php.

Here are the urlManager rules :


		'urlManager'=>array(

			'urlFormat'=>'path',

			'showScriptName'=>false,

                        'rules'=>array(

				'stock'=>array('site/stock', 'urlSuffix'=>$url_prefix ),#x

				'about-us'=>array('site/about', 'urlSuffix'=>$url_prefix ),#x

                                'terms-of-website'=>array('site/termsofwebsite', 'urlSuffix'=>$url_prefix ),#x

                                'terms-of-sale'=>array('site/termsofsale', 'urlSuffix'=>$url_prefix ),#x

                                'privacy-policy'=>array('site/privacypolicy', 'urlSuffix'=>$url_prefix ),#x

                                '/'=>array('site/index', 'urlSuffix'=>$url_prefix ),#x

                                'after-sale-services'=>array('site/aftersaleservices', 'urlSuffix'=>$url_prefix ),#x

                                'garage-services'=>array('site/garageservices', 'urlSuffix'=>$url_prefix ),#x

				'warranties'=>array('site/warranties', 'urlSuffix'=>$url_prefix ),#x

				'how-it-works'=>array('site/howitworks', 'urlSuffix'=>$url_prefix ),#x'stock'=>array('site/stock', 'urlSuffix'=>$url_prefix ),#x

				'apply-now'=>array('site/apply', 'urlSuffix'=>$url_prefix ),#x

				'contact-us'=>array('site/contactus', 'urlSuffix'=>$url_prefix ),#x'stock'=>array('site/stock', 'urlSuffix'=>$url_prefix ),#x

				'advanced-search'=>array('site/search', 'urlSuffix'=>$url_prefix ),#x

				'listing/<car:.*?>'=>array('site/listing', 'urlSuffix'=>$url_prefix ),#x

                'car/<id:.*?>/<title:.*?>'=>array('site/product', 'urlSuffix'=>$url_prefix ),#x,

				

			),

		),

One other thing I should probably mention, there is a directory called “framework” which seems to be the workings of yii framework, on the linux server this directory existed at the same level as the “www root” directory, however on the new windows server I couldn’t put this directory in the same place because of permission issues, so I copied in within the “www root” directory.

However in the index.php file I changed :

$yii=dirname(FILE).’/../framework/yii.php’;

to :

$yii=dirname(FILE).’\framework\yii.php’;

to accomodate for this change.

Thanks,

Paul

Hi,

We always encounter this issue due to missing .htaccess in the root directory of your application. We cannot copy it because in linux, files starting with . is considered as hidden file.

Does the 404 error come from IIS or Yii? The urlManager rules you posted are set up for pretty URLs and to hide index.php. In a shared environment you may not be able to control this, but Yii under IIS works best with the following tweaks:

  1. FastCGI enabled - "http://technet.microsoft.com/en-us/library/dd239230(v=ws.10).aspx"

  2. URL Rewrite module - "http://www.iis.net/downloads/microsoft/url-rewrite"

Thanks everyone.

I’ve now resolved the issue, it was a url rewriting issue, the .htaccess file did copy over from the linux server but because the new server uses IIS (not apache) I had to do the url rewriting in a different way.

Glad you solved the problem! :)