Jump to content

Rewrite rules .htaccess for facebook app trailing slash and exclude internal files js/css/images/etc


Recommended Posts

I just started working with my first .htaccess RewriteRule because when submitting a facebook app, it must end with either a trailing slash or be a dynamic URL. My domain already is used for another project so I put my app into a sub-directory so it looks like this



I'm trying to convert it to be in this format



I can't use app's sub-directory as index.html or index.php which is already used outside of a facebook with Google Ads, since Google Ads are illegal to be used on facebook, I created a copy of the index.html called index2.html without any Google ads on it.


I started messing around with .htaccess and I got it semi-working but in Google Chrome it seems to detect the URL as being a folder and starts loading the stylesheets and javascript scripts from the fake virtual directory assuming that fbapp is a directory when it should be app/file.xxx instead of app/fbapp/file.xxx


Here is what I got so far I still don't understand how to use Rewrite Condionals but from my understanding if the RewriteCond is triggered it will run the line right under it, otherwise it will skip it somehow and go to the third line which works fine as long as it's not a script/image/stylesheet/etc...

RewriteEngine on
RewriteCond $1 !^(favicon\.ico|favicon\.png|robots\.txt|css|js) [NC]
RewriteRule ^(.*)$ $1 [E=BASE:%1]

RewriteRule ^fbapp index2.html [E=BASE:%1]
Edited by sspoke
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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.