ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Loading content with Ajax when index.php has been removed by htaccess

April 07, 2011 4:13pm

Subscribe [2]
  • #1 / Apr 07, 2011 4:13pm

    jamestowers

    53 posts

    I’ve removed index.php from my urls but now none of the content i’m loading with ajax is being loaded, it returns a 301 “moved permanently”, if i add index.php to the links they then work again.

    Also if I take the url i’m trying to load in and paste it directly into the address bar it works fine.

    Is there a special trick to getting this to work?

  • #2 / Apr 08, 2011 6:34am

    John Henry Donovan

    12339 posts

    jamestowers,

    We don’t support the removal of index.php via a htaccess.
    But you most likely need to make a rule change to allow it.

    If you wish to post your htaccess here and the ajax method you are using I can move this to the CodeShare Corner for additional community help?

  • #3 / Apr 08, 2011 6:35am

    jamestowers

    53 posts

    Thanks John,

    here it is:

    DirectoryIndex index.php index.html
    
    # Expression Engine mod_rewrite to remove "index.php"
    RewriteEngine On
    Options +FollowSymLinks
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?/$1
    
    RewriteCond %{HTTPS} off
    RewriteCond %{REQUEST_URI} (store/checkout|store/review-order|store/view_basket|store/x_view_basket_embed|member|account|assets|campaigns|js|ajax|includes|ajax|site)
    RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
    
    RewriteCond %{HTTPS} on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !(store/checkout|store/review-order|store/view_basket|store/x_view_basket_embed|member|account|assets|campaigns|js|ajax|includes|ajax|site)
    RewriteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
  • #4 / Apr 08, 2011 6:38am

    John Henry Donovan

    12339 posts

    Moving to CS Corner for you

  • #5 / Apr 08, 2011 6:42am

    jamestowers

    53 posts

    Sorry, seeing the code when I posted it there made we realise something, I was calling templates in the “store” template group that weren’t listed in the {REQUEST_URI}.

    I changed the above to this and it seems to work now.

    DirectoryIndex index.php index.html
    
    # Expression Engine mod_rewrite to remove "index.php"
    RewriteEngine On
    Options +FollowSymLinks
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?/$1
    
    RewriteCond %{HTTPS} off
    RewriteCond %{REQUEST_URI} (store|member|account|assets|campaigns|js|ajax|includes|ajax|site)
    RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
    
    RewriteCond %{HTTPS} on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !(store|member|account|assets|campaigns|js|ajax|includes|ajax|site)
    RewriteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases