mod_rewrite, conditional RewriteBase? |
[eluser]Anthony Linton[/eluser]
Hi everyone, I'm having trouble with my .htaccess file. Here it is as it stands. Code: #http://codeigniter.com/wiki/mod_rewrite/ This works fine. My problem is that during development I'm working at http://localhost/ps3vs360/ and then deploying it to my production server at http://ps3vs360.com/ Normally, this wouldn't be a problem. I could just set RewriteBase /ps3vs360/ on the local system and change it to RewriteBase / via FTP on the server. However, I've recently started using subversion which means the files must be identical on both my local server and the remote server or it'll moan at me. You can see the problem if you go to http://ps3vs360.com/quiz/, I get 500 Internal Server Error. I definitely have mod_rewrite enabled on the server etc so it is working ok, see here for my server settings: http://ps3vs360.com/phpinfo.php so it must be the RewriteBase. Is there a way for me to check if it's localhost, and if so, use the directory /ps3vs360/ and if not use RewriteBase / ? I've googled for a solution to this and can't find one, and I suck at htaccess conditions. Thank you ![]()
[eluser]Krzemo[/eluser]
Files dont have to be identical. Just add your local .htaccess to svn:ignore and it wont commit nor update...
[eluser]Anthony Linton[/eluser]
ah yes, I use beanstalk for deploying from the repository and apparently if I change the permissions on .htaccess on the remote server it'll just leave it. Thanks! ![]()
[eluser]cahva[/eluser]
Other way is to define local address for your project and use it as a vhost. That way structure would be the same always and you could have the same .htaccess file without rewritebase. For example this ps3vs360 project you would define host local.ps3vs360.com and point it 127.0.0.1. After that, add local.ps3vs360.com to your dev server's vhosts. I use windows as development server with Wamp and heres the steps I make for a new project: 1. Create the directory for the project (D:\web\testproject.com\public_html). I always put code outside of webroot so I create the public_html also on development server(and to have the exact same structure than on production webserver) 2. Open C:\WINDOWS\system32\drivers\etc\hosts - add line: 127.0.0.1 local.testproject.com 3. Open vhosts file(I have it on C:\wamp\vhosts\vhosts.conf, which is included in the main httpd.conf) and add vhost: Code: <VirtualHost *:80> Done! ![]()
[eluser]Anthony Linton[/eluser]
Cahva, the perfect solution! I used a guide @ http://maff.ailoo.net/2008/07/set-up-mul...r-windows/ for XAMPP. I can now browse to http://ps3vs360/ instead of http://localhost/ps3vs360/ and not have to mess around with sub-directory issues. Thanks very much.
|
Welcome Guest, Not a member yet? Register Sign In |