Welcome Guest, Not a member yet? Register   Sign In
.htaccess and rewrite on mac
#1

[eluser]learning_php[/eluser]
Hi,

i recently purchased a Macbook and i am having a little trouble getting my page links to work. I know its something to do with the way that i have set up my .htaccess file but cannot seem to get it to work and i keep getting 404 errors? I have set up MAMP as i localhost so the Mod_rewite should already be working?

This is what i have for my .htaccess
Code:
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /websites/mysite/
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php/$1 [QSA,NC,L]
</IfModule>

<IfModule !mod_rewrite.c>
  # If we donít have mod_rewrite installed, all 404ís
  # can be sent to index.php, and everything works as normal.

  ErrorDocument 404 /index.php
</IfModule>

controller:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
&lt;html&gt;

&lt;head&gt;


&lt;link rel="stylesheet" type="text/css" title="wallpaper-theme" href="css/stylesheet2.css"  /&gt;
&lt;link rel="alternate stylesheet" type="text/css" title="carbon-theme"  href="css/stylesheet1.css" /&gt;

&lt;!--This script should appear below your LINK stylesheet tags --&gt;

[removed]

/***********************************************
* Style Sheet Switcher v1.1- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/

[removed]
&lt;meta http-equiv="Content-Type" content="text/html; charset=encoding"&gt;

&lt;title&gt;HomePage&lt;/title&gt;
&lt;/head&gt;
    &lt;body&gt;
    
    <div id = "container">
        <div id = "header">
            <div id= "nav">
                <div id = "tab">
            <div id = "navtext"><p>&lt;?php echo anchor('/index', 'Home');?&gt;</p></div>
            </div>
            <div id = "tab">
         <div id = "navtext"><p>&lt;?php echo anchor('about/About', 'About');?&gt;</p></div>
        </div>
                <div id = "tab">
                      <div id = "navtext">Work</div>
                  </div>
                  <div id = "tab">
                      <div id = "navtext">Contact</div>
                  </div>
                  <div id = "tab">
                      <div id = "navtext">Blog</div>
                  </div>
            </div>
        </div>
        
        <div id = "content">
            <div id ="textbox">
                <div id ="blogtextbox"></div>
            </div>
            <div id = "sidetextbox"></div>
        </div>
    </div>

    
    &lt;/body&gt;
&lt;/html&gt;
#2

[eluser]tomcode[/eluser]
Take out the if clauses in the .htaccess, if it does not work, we'll see further

Edit : comment the Error document while testing
#3

[eluser]learning_php[/eluser]
hi,

I move the file directly in to the htdocs folder so the path is now htdocs/mysite and I changed the .htacess but still does not work!

Code:
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php/$1 [QSA,NC,L]
</IfModule>
#4

[eluser]tomcode[/eluser]
What happens if You comment the IfModule clause :

Code:
# <IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php/$1 [QSA,NC,L]
# </IfModule>

Edit : Try also :

Code:
# <IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /mysite/
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php/$1 [QSA,NC,L]
# </IfModule>
#5

[eluser]learning_php[/eluser]
I still get the 404 with this url/mysite/about/index was not found on this server
#6

[eluser]tomcode[/eluser]
Do You get CI's error or Apache's error ?

Does the app work with index.php ?

if the app is located at /htdocs/mysite, then put the .htaccess into the root folder of Your app:

/htdocs/mysite/.htaccess

if it still does not work, create an error in Your .htaccess, if You do not get a 500 server eror, then apache ignores Your .htacess file
#7

[eluser]learning_php[/eluser]
My main controller with my homepage opens correctly with the url localhost:8888/mysite but when i try and link away i get a 404.
#8

[eluser]tomcode[/eluser]
Please be more precise:

Do You get CI's 404 errors or Apache's 404 error ?

Do You mean with or without .htaccess ?

Have You set Your base_url in the config file to http://localhost:8888/mysite/ ?
#9

[eluser]danmontgomery[/eluser]
http://old.nabble.com/Mod_rewrite-and-Ma...42459.html

Have you tried this?
#10

[eluser]learning_php[/eluser]
its an apache apache 404 error.
with my .htaccess file in the mysite root folder as the following:
Code:
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php/$1 [QSA,NC,L]
</IfModule>

and by base url is set to localhost:8888/mystite/

Which URI protocol should i be using as i currenlty have it set to Auto?




Theme © iAndrew 2016 - Forum software by © MyBB