7

For some reason the CraftCMS URL rewrite is not working on GoDaddy shared hosting server.

Currently by .htaccess file looks like this

Options +FollowSymLinks -Multiviews
<IfModule mod_rewrite.c>
   RewriteEngine On
   # Send would-be 404 requests to Craft
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
   RewriteRule (.+) index.php?p=$1 [QSA,L]
</IfModule>

Has anyone encountered this problem? Can someone help me solve this?

Update

I am not sure any more if this a url rewrite problem. As when I access an entry such as http://aspaceboydream.com/comic/so-this-is-me, it loads correctly. But when I use the function:

url('comic')

to construct the urls of the different channels, the URLs are being constructed as http://aspaceboydream.com/index.php?p=comic

9

I solved the problem and am writing it down for future people encountering the same problem.

Add the following configuration to the your craft/config/general.php config file:

'omitScriptNameInUrls' => true

URLs will start to work fine.

  • this does not affect actionUrl method it seems... – Manticore Jan 26 '17 at 14:12
5

Edit: Quick answer (as per RitterKnight's comment)... just add RewriteBase / to the top of your .htaccess file in the root of your public/public_html directory.


I am on the same type of shared GoDaddy server, and continued to experience the same issue regardless of wether 'omitScriptNameInUrls' was set to true. I would get an "Internal Server Error" on all pages, apart from the homepage.

I have since found a solution which is specifically tailored to GoDaddy sufferers. My .htaccess file now looks like this:

DirectoryIndex index.php
AddDefaultCharset utf-8

RewriteEngine on
Options +FollowSymlinks -MultiViews -Indexes   

RewriteBase /

<IfModule mod_rewrite.c>
   RewriteEngine On
   # Send would-be 404 requests to Craft
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
   RewriteRule (.+) index.php?p=$1 [QSA,L]
</IfModule>

Success! I now have a Craft installation on a GoDaddy shared server, with clean-urls working!

  • 1
    I'm guessing the addition of the line RewriteBase / is what's making this work. IIRC the last time I used GoDaddy, it ignored DirectoryIndex and used index.php as the default anyway but YMMV. You don't need the RewriteEngine On directive in there twice—you have it once in the IfModule block—where it usually is—and again above it, outside the block. By convention, RewriteBase / usually sits below inside the ifModule block on the off chance mod_rewrite is turned off or not installed. – RitterKnight Jul 12 '15 at 16:49
3

I have lord knows how many sites on GoDaddy (too many). The key to it is RewriteBase. Just add it to the default .htaccess and you're all set.

  • Nice, thank you. So those first 4 lines in my comment are unnecessary. – Mark Notton Jul 12 '15 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.