How about renaming the SiteController.php - so that we don’t have any /site/etc in the URL’s
I know much of this is mod_rewrite, however the paths inside Yii must need fixing to accomodate all of these things. I think the documentation is great but there realy are very few examples . I hope you can shed some light in these issues!
Note: <view:(contact-us)> accepts regular expressions if you like to use them.
Make sure your .htaccess in your application root looks like as follows:
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
You should now have clean URL’s and be able to change the URL’s as you like.
I’m an drupal developer, and drupal does this by rewriting the urls with an .htaccess file. Changed a part of this .htaccess file to use this within my yii setup.
<IfModule mod_rewrite.c>
RewriteEngine on
Rewrite URLs of the form ‘x’ to the form ‘index.php?r=x’.
I’m pretty new to Yii, and PHP as well. I’ve been trying to implement this in a project, but when I put "‘showScriptName’ => false, " into my urlManager, I end up getting 404 Not Found errors. I’ve followed along with this post and have pretty much copy and pasted the .htaccess and the urlManager array, making minor tweaks in the array so the names match up with my pages, which are mostly the ones you generate in the tutorial (i.e. “testdrive”): about, contact, etc… Any ideas why this would be happening?
Then I restarted all services on my wamp server. Still having 404 Not Found errors. I can login fine, but once I click "Contact", "About", or any other links, the error pops up.
I had something similar. So for good measure, I copied yours into my code. Still the same thing: "The requested URL /mysite/site/contact was not found on this server."
It might also be helpful for me to mention that the way my site works is that you have to go through the login page to access any other part of the site (which is why I have <view:(index)’ => 'site/login)
You may need to change AllowOverride (to All or possibly Options) in httpd.conf. Check the Apache error log for messsages like "Options not allowed"
So if my step 2 succeeded (e.g. yoursite/site/login) the rewrite actually is in effect (no need to change AllowOverride). But I don’t understand whether you can access other pages from the browser address field (e.g. yoursite/site/index).
The rest is what I mentioned in my step 3, try to add such links in a view. Then fix the menu links (e.g ‘/controller/action’) or possibly use createUrl().