Working Locally Help
This is an open discussion with 10 replies, filed under Troubleshooting.
Search
I had a similar problem with my localhost setup. For some reason rewrite wasn't working correctly at first. What's your environment? Did you use MAMP? MacPorts?
I'm on leopard so I run Apache (With web sharing in system preferences) and PHP with the built in versions, and I downloaded MySQL. But I could try MAMP or MacPorts if you recommend it.
Well I'm not a Mac expert, so take this with a grain of salt, but here's what happened to me:
I installed MAMP, and ended up with a problem very similar to yours. Though everything was installed and enabled, my rewrites just weren't working. So I uninstalled MAMP, uninstalled the default OS X version of Apache, and turned off web sharing. Then I installed the whole stack via MacPorts and now everything works perfectly.
huh, not sure if I can take such a big step since I have a lot going on this apache, but if all else fails I will try this, thanks for your help though!
I followed the steps in http://blog.jameshiggs.com/2007/12/25/getting-wordpress-mod_rewrite-and-leopard-to-work-together/ and this got htaccess to work, however now I need to figure out the .htaccess files since now all I get are 403 error pages.
Here is my htaccess code, if someone finds something wrong, could you please help me out?
### Symphony 2.0 - Do not edit ### <IfModule mod_rewrite.c> RewriteEngine on RewriteBase /~tukaiz/stephen-korecky/ ### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico" RewriteCond %{REQUEST_FILENAME} favicon.ico [NC] RewriteRule .* - [S=14] ### IMAGE RULES RewriteRule ^image\/3\/([0-9]+)\/([0-9]+)\/([1-9])\/([a-fA-f0-9]{3,6})(\/(0|1))?\/(.+)\.(jpg|gif|jpeg|png|bmp)$ /symphony/image.php?param=3:$1:$2:$3:$4:$6:$7.$8 [L] RewriteRule ^image\/2\/([0-9]+)\/([0-9]+)\/([1-9])(\/(0|1))?\/(.+)\.(jpg|gif|jpeg|png|bmp)$ /symphony/image.php?param=2:$1:$2:$3:0:$5:$6.$7 [L] RewriteRule ^image\/1\/([0-9]+)\/([0-9]+)(\/(0|1))?\/(.+)\.(jpg|gif|jpeg|png|bmp)$ /symphony/image.php?param=1:$1:$2:0:0:$4:$5.$6 [L] RewriteRule ^image(\/(0|1))?\/(.+)\.(jpg|gif|jpeg|png|bmp)$ /symphony/image.php?param=0:0:0:0:0:$2:$3.$4 [L] ### CHECK FOR TRAILING SLASH - Will ignore files RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !/$ RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*)$ /$1/ [L,R=301] ### MAIN REWRITE - This will ignore directories RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)\/$ /stephen-korecky/index.php?page=$1&%{QUERY_STRING} [L] </IfModule> DirectoryIndex index.php IndexIgnore * ######
I think Leopard turns off mod_rewrite in apache by default. You might have to update your httpd.conf file to allow it. Look for AllowOverride.
That said, I strongly suggest you use MAMP when developing on localhost. It's much easier to manage than the pre-installed packages. I've tried both, and I favor the standalone app.
well mod_rewrite is not "off" per say, however you need to fix your user conf file like so:
<Directory "/Users/USERNAMEHERE/Sites"> Options Indexes MultiViews AllowOverride All Order allow,deny Allow from all </Directory>
Then htaccess / mod_rewrite will work. Which it is on my machine, however the problem is configuring the htaccess for localhost use.
I have to use my installed version of Apache because 1. It's easier for me not to have to worry about apache running all the time, 2. I work with Ruby on Rails and I use Passenger which relies on my Apache setup.
I found by adding:
Options +FollowSymLinks
to my htaccess, I can now load the home page with htaccess enabled, however I still can't load my sub-directory pages. Anyone have any ideas?
It looks like you tried to modify the .htaccess manually. Try a fresh install in this directory, then copy the .htaccess file. You'll probably want something like this:
### Symphony 2.0 - Do not edit ### <IfModule mod_rewrite.c> RewriteEngine on RewriteBase /~tukaiz/stephen-korecky/ ### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico" RewriteCond %{REQUEST_FILENAME} favicon.ico [NC] RewriteRule .* - [S=14] ### IMAGE RULES RewriteRule ^image\/3\/([0-9]+)\/([0-9]+)\/([1-9])\/([a-fA-f0-9]{3,6})(\/(0|1))?\/(.+)\.(jpg|gif|jpeg|png|bmp)$ /~tukaiz/stephen-korecky/symphony/image.php?param=3:$1:$2:$3:$4:$6:$7.$8 [L] RewriteRule ^image\/2\/([0-9]+)\/([0-9]+)\/([1-9])(\/(0|1))?\/(.+)\.(jpg|gif|jpeg|png|bmp)$ /~tukaiz/stephen-korecky/symphony/image.php?param=2:$1:$2:$3:0:$5:$6.$7 [L] RewriteRule ^image\/1\/([0-9]+)\/([0-9]+)(\/(0|1))?\/(.+)\.(jpg|gif|jpeg|png|bmp)$ /~tukaiz/stephen-korecky/symphony/image.php?param=1:$1:$2:0:0:$4:$5.$6 [L] RewriteRule ^image(\/(0|1))?\/(.+)\.(jpg|gif|jpeg|png|bmp)$ /~tukaiz/stephen-korecky/symphony/image.php?param=0:0:0:0:0:$2:$3.$4 [L] ### CHECK FOR TRAILING SLASH - Will ignore files RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !/~tukaiz/stephen-korecky$ RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*)$ /~tukaiz/stephen-korecky/$1/ [L,R=301] ### MAIN REWRITE - This will ignore directories RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)\/$ /~tukaiz/stephen-korecky/index.php?page=$1&%{QUERY_STRING} [L] </IfModule> DirectoryIndex index.php IndexIgnore * ######
@bauhouse Perfect! Thank you! you I just had to add the
Options +FollowSymLinks
Now everything works just fine! Thanks everyone for your input and help!
### Symphony 2.0 - Do not edit ### <IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine on RewriteBase /~stephen/stephen-korecky/ ### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico" RewriteCond %{REQUEST_FILENAME} favicon.ico [NC] RewriteRule .* - [S=14] ### IMAGE RULES RewriteRule ^image\/3\/([0-9]+)\/([0-9]+)\/([1-9])\/([a-fA-f0-9]{3,6})(\/(0|1))?\/(.+)\.(jpg|gif|jpeg|png|bmp)$ /~stephen/stephen-korecky/symphony/image.php?param=3:$1:$2:$3:$4:$6:$7.$8 [L] RewriteRule ^image\/2\/([0-9]+)\/([0-9]+)\/([1-9])(\/(0|1))?\/(.+)\.(jpg|gif|jpeg|png|bmp)$ /~stephen/stephen-korecky/symphony/image.php?param=2:$1:$2:$3:0:$5:$6.$7 [L] RewriteRule ^image\/1\/([0-9]+)\/([0-9]+)(\/(0|1))?\/(.+)\.(jpg|gif|jpeg|png|bmp)$ /~stephen/stephen-korecky/symphony/image.php?param=1:$1:$2:0:0:$4:$5.$6 [L] RewriteRule ^image(\/(0|1))?\/(.+)\.(jpg|gif|jpeg|png|bmp)$ /~stephen/stephen-korecky/symphony/image.php?param=0:0:0:0:0:$2:$3.$4 [L] ### CHECK FOR TRAILING SLASH - Will ignore files RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !/~stephen/stephen-korecky$ RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*)$ /~stephen/stephen-korecky/$1/ [L,R=301] ### MAIN REWRITE - This will ignore directories RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)\/$ /~stephen/stephen-korecky/index.php?page=$1&%{QUERY_STRING} [L] </IfModule> DirectoryIndex index.php IndexIgnore * ######
Create an account or sign in to comment.
Hey everyone, I'm trying to work on my site locally (like you should) however I can never seem to load anything but the home page, here is an example: If I load http://localhost/~tukaiz/stephen-korecky/ it runs the home page just fine, however if I want to go to my about page i.e. http://localhost/~tukaiz/stephen-korecky/about or (/about/) it does not load the pages and I just my page not found.
Am I just calling up the page wrong? My config file is set for that directory and mod_rewrite is on in my httpd.conf file so not sure what else it could be. Any help would be very appreciated!
p.s. I'm on a Mac