Jump to content

Rewrite ALL pages to Index - Kils all JavaScript


unemployment

Recommended Posts

I'm in the process of trying to build a single page application and I need to rewrite all my page to the index.php file, but I'm not sure how to do it.  When I try with the code below, all of my script files break. Any suggestions?

 

RewriteRule ^(.*)$ index.php?page=$1 [L]

Make it only rewrite if the requested file doesn't exist. Before the RewriteRule put

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

 

That fixed the script errors I was having but this isn't exactly functioning perfectly.  Right now if I go to index it works great and if I use Javascript (Backbone.js) to load my next view and navigate to the next page with the HTML5 History API, that works.  The problem is when loading a page that has a query string.  For instance, if I go to index/login, the page redirect back to index and then my JS will load the login view.  This is not what I want to have happen.  It is essentially causing the screen to flicker since it loads the index first and then the JS view.  Not sure how to solve this.

 

That sounds far more likely to be a JavaScript issue.

 

Yeah... I'm actually changing my approach.  I was originally think I'd build a single page app, but not I think getting SEO benefit from that is just going to too difficult.  I decided on a hybrid approach where I will only use backbone to render application pages and have other pages be generated by PHP

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.